@cindex @option{kubernetes} method
Integration for containers in Kubernetes pods. The host name is
-@samp{@var{pod}}, or @samp{@var{container}.@var{pod}} if an
-explicit container name shall be used. Otherwise, the first container
-in a pod is used.
+@samp{@var{pod}}, or @samp{@var{container}.@var{pod}} if an explicit
+container name shall be used. Otherwise, the first container in a pod
+is used. @samp{@var{pod}%@var{namespace}} as host name allows to use
+another namespace but the default one. This can also be combined with
+the @samp{@var{container}.} prefix.
This method does not support user names.
@vindex tramp-kubernetes-namespace
@value{tramp} uses the default Kubernetes context and namespace. If
another context or namespace shall be used, configure the user options
-@code{tramp-kubernetes-context} and @code{tramp-kubernetes-namespace}.
+@code{tramp-kubernetes-context} or @code{tramp-kubernetes-namespace},
+respectively. An explicit @samp{%@var{namespace}} postfix in the host
+name takes precedence.
@node Auto-save File Lock and Backup
\f
* Installation Changes in Emacs 31.1
-** When using GCC 4 or later to build Emacs on 32-bit x86 systems,
-'configure' now defaults to using the GCC options -mfpmath=sse (if the
-host system supports SSE2) or -fno-tree-sra (if not). These GCC options
-work around GCC bug 58416, which can cause Emacs to behave incorrectly
-in rare cases.
+** Changed GCC default options on 32-bit x86 systems.
+When using GCC 4 or later to build Emacs on 32-bit x86 systems,
+'configure' now defaults to using the GCC options '-mfpmath=sse' (if the
+host system supports SSE2) or '-fno-tree-sra' (if not). These GCC
+options work around GCC bug 58416, which can cause Emacs to behave
+incorrectly in rare cases.
\f
* Startup Changes in Emacs 31.1
---
*** 'whitespace-cleanup' now adds missing newline at end of file.
-If 'whitespace-style' includes 'missing-newline-at-eof (which is the
+If 'whitespace-style' includes 'missing-newline-at-eof' (which is the
default), the 'whitespace-cleanup' function will now add the newline.
** Eshell
---
-*** New option 'eshell-command-async-buffer'.
+*** New user option 'eshell-command-async-buffer'.
This option lets you tell 'eshell-command' how to respond if its output
buffer is already in use by another invocation of 'eshell-command', much
like 'async-shell-command-buffer' does for 'shell-command'. By default,
+++
*** 'eshell-execute-file' is now an interactive command.
-Interactively, this now prompts for a script file to execute. With the
+Interactively, this now prompts for a script file to execute. With the
prefix argument, it will also insert any output into the current buffer
at point.
Points" node in the Eshell manual for more details.
+++
-*** Eshell's built-in "wait" command now accepts a timeout.
-By passing "-t" or "--timeout", you can specify a maximum time to wait
+*** Eshell's built-in 'wait' command now accepts a timeout.
+By passing '-t' or '--timeout', you can specify a maximum time to wait
for the processes to exit. Additionally, you can now wait for external
processes by passing their PIDs.
Sliced images allow for more intuitive scrolling up/down by letting you
scroll past each slice, instead of jumping past the entire image.
Previously, SHR sliced images when zoomed to their original size, no
-matter how large or small that was). Now, SHR slices any images taller
+matter how large or small that was. Now, SHR slices any images taller
than 'shr-sliced-image-height'. For more information, see the "(eww)
Advanced" node in the EWW manual.
region. It is bound to 'C-c C-t t' in 'go-ts-mode'.
The 'go-ts-mode-test-this-file' command runs all unit tests in the current
-file. It is bound to 'C-c C-t f' in 'go-ts-mode'.
+file. It is bound to 'C-c C-t f' in 'go-ts-mode'.
The 'go-ts-mode-test-this-package' command runs all unit tests under the
package of the current buffer. It is bound to 'C-c C-t p' in 'go-ts-mode'.
-The 'go-ts-mode-build-tags' variable is available to set a list of build
-tags for the test commands.
+The 'go-ts-mode-build-tags' user option is available to set a list of
+build tags for the test commands.
** Emacs Lisp mode
---
*** Dedicated buffer for plain text contents.
When switching to the plain text contents with 'doc-view-open-text',
-DocView now creates a dedicated buffer to display it. 'C-c C-c' gets you
+DocView now creates a dedicated buffer to display it. 'C-c C-c' gets you
back to real DocView buffer if it still exists.
+
+** Tramp
+
++++
+*** Connection method "kubernetes" supports now optional namespace.
+The host name for Kubernetes connections can be of kind
+[CONTAINER.]POD[%NAMESPACE], in order to specify the namespace to be
+used. This overrides the setiing in 'tramp-kubernetes-namespace', if
+any.
+
\f
* New Modes and Packages in Emacs 31.1
---
** Process execution has been optimized on Android.
-The run-time performance of subprocesses on recent Android releases
-where a userspace executable loader is required has been optimized on
-systems featuring Linux 3.5.0 and above.
+The run-time performance of subprocesses on recent Android releases,
+where a userspace executable loader is required, has been optimized on
+systems featuring GNU/Linux 3.5.0 and above.
\f
----------------------------------------------------------------------
;;
;; Open file in a Kubernetes container:
;;
-;; C-x C-f /kubernetes:[CONTAINER.]POD:/path/to/file
+;; C-x C-f /kubernetes:[CONTAINER.]POD[%NAMESPACE]:/path/to/file
;;
;; Where:
;; POD is the pod to connect to.
;; CONTAINER is the container to connect to (optional).
;; By default, the first container in that pod will
;; be used.
-;;
-;; Completion for POD and accessing it operate in the current
-;; namespace, use this command to change it:
-;;
-;; "kubectl config set-context --current --namespace=<name>"
+;; NAMESPACE is the namespace to be used (optional).
;;
;;
;;
:type '(choice (const :tag "Use default" nil)
(string)))
-(defcustom tramp-kubernetes-namespace "default"
- "Namespace of Kubernetes."
+(defcustom tramp-kubernetes-namespace nil
+ "Namespace of Kubernetes.
+If it is nil, the current namespace will be used. An explicit NAMESPACE
+in the remote file name host part will override it."
:group 'tramp
- :version "30.1"
- :type 'string)
+ :version "31.1"
+ :type '(choice (const :tag "Use default" nil)
+ (string)))
;;;###tramp-autoload
(defcustom tramp-toolbox-program "toolbox"
(push (concat elt "." (car line)) names)))
(mapcar (lambda (name) (list nil name)) (delq nil names))))))
+;; <https://kubernetes.io/docs/concepts/overview/working-with-objects/names/>
+;; `lower' could also match non-ascii letters. But since this regexp
+;; is only used for strings matching `tramp-host-regexp', this doesn't
+;; hurt.
+(defconst tramp-kubernetes--name-regexp (rx (** 1 63 (any lower digit "-")))
+ "Regexp matching kubernetes names.")
+
(defconst tramp-kubernetes--host-name-regexp
- (rx (? (group (regexp tramp-host-regexp)) ".")
- (group (regexp tramp-host-regexp)))
- "The CONTAINER.POD syntax of kubernetes host names in Tramp.")
+ (rx bos (? (group (regexp tramp-kubernetes--name-regexp)) ".")
+ (group (regexp tramp-kubernetes--name-regexp))
+ (? "%" (group (regexp tramp-kubernetes--name-regexp))) eos)
+ "The CONTAINER.POD%NAMESPACE syntax of kubernetes host names in Tramp.")
;;;###tramp-autoload
(defun tramp-kubernetes--container (vec)
(match-string 2 host)))
""))
+;;;###tramp-autoload
+(defun tramp-kubernetes--namespace (vec)
+ "Extract the namespace from a kubernetes host name in VEC.
+Use `tramp-kubernetes-namespace' otherwise."
+ (or (when-let ((_ vec)
+ (host (tramp-file-name-host vec)))
+ (and (string-match tramp-kubernetes--host-name-regexp host)
+ (match-string 3 host)))
+ tramp-kubernetes-namespace))
+
;; We must change `vec' and `default-directory' to the previous hop,
;; in order to run `process-file' in a proper environment.
(defmacro tramp-skeleton-kubernetes-vector (vec &rest body)
(cond
((null ,vec) tramp-null-hop)
((equal (tramp-file-name-method ,vec) tramp-kubernetes-method)
+ ;; Sanity check. We don't support `user' or `port' in
+ ;; Kubernetes file names.
+ (when (or (tramp-file-name-user-domain ,vec)
+ (tramp-file-name-port ,vec))
+ (tramp-user-error ,vec "Wrong kubernetes file name syntax"))
(if (tramp-file-name-hop ,vec)
(tramp-dissect-hop-name (tramp-file-name-hop ,vec))
tramp-null-hop))
#'identity
`(,(when-let ((context (tramp-kubernetes--current-context vec)))
(format "--context=%s" context))
- ,(when tramp-kubernetes-namespace
- (format "--namespace=%s" tramp-kubernetes-namespace)))
+ ,(when-let ((namespace (tramp-kubernetes--namespace vec)))
+ (format "--namespace=%s" namespace)))
" "))
;;;###tramp-autoload
;; This variable will be eval'ed in `tramp-expand-args'.
(tramp-extra-expand-args
. (?a (tramp-kubernetes--container (car tramp-current-connection))
- ?h (tramp-kubernetes--pod (car tramp-current-connection))
- ?x (tramp-kubernetes--context-namespace
- (car tramp-current-connection)))))
+ ?h (tramp-kubernetes--pod (car tramp-current-connection))
+ ?x (tramp-kubernetes--context-namespace
+ (car tramp-current-connection)))))
"Default connection-local variables for remote kubernetes connections.")
(connection-local-set-profile-variables