diff options
Diffstat (limited to 'lisp/net/tramp-container.el')
-rw-r--r-- | lisp/net/tramp-container.el | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/lisp/net/tramp-container.el b/lisp/net/tramp-container.el index e104babed27..0879d6f1856 100644 --- a/lisp/net/tramp-container.el +++ b/lisp/net/tramp-container.el @@ -101,7 +101,8 @@ This function is used by `tramp-set-completion-function', please see its function help for a description of the format." - (when-let ((raw-list (shell-command-to-string + (when-let ((default-directory tramp-compat-temporary-file-directory) + (raw-list (shell-command-to-string (concat tramp-docker-program " ps --format '{{.ID}}\t{{.Names}}'"))) (lines (split-string raw-list "\n" 'omit)) @@ -121,7 +122,8 @@ see its function help for a description of the format." This function is used by `tramp-set-completion-function', please see its function help for a description of the format." - (when-let ((raw-list (shell-command-to-string + (when-let ((default-directory tramp-compat-temporary-file-directory) + (raw-list (shell-command-to-string (concat tramp-kubernetes-program " get pods --no-headers " "-o custom-columns=NAME:.metadata.name"))) @@ -130,6 +132,24 @@ see its function help for a description of the format." (list nil name)) names))) +(defun tramp-kubernetes--current-context-data (vec) + "Return Kubernetes current context data as JSONPATH string." + (with-temp-buffer + (when (zerop + (tramp-call-process + vec tramp-kubernetes-program nil t nil + "config" "current-context")) + (goto-char (point-min)) + (let ((current-context (buffer-substring (point) (line-end-position)))) + (erase-buffer) + (when (zerop + (tramp-call-process + vec tramp-kubernetes-program nil t nil + "config" "view" "-o" + (format + "jsonpath='{.contexts[?(@.name == \"%s\")]}'" current-context))) + (buffer-string)))))) + ;;;###tramp-autoload (defvar tramp-default-remote-shell) ;; Silence byte compiler. @@ -165,6 +185,7 @@ see its function help for a description of the format." ("-it") ("--") ("%l"))) + (tramp-config-check tramp-kubernetes--current-context-data) (tramp-remote-shell ,tramp-default-remote-shell) (tramp-remote-shell-login ("-l")) (tramp-remote-shell-args ("-i" "-c")))) |