From: Eshel Yaron Date: Wed, 24 Jul 2024 05:15:45 +0000 (+0200) Subject: (kubed-current-namespace): Fix handling of multiple contexts X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=ecb218884a871d292cf507571357834b6498babb;p=emacs.git (kubed-current-namespace): Fix handling of multiple contexts --- diff --git a/lisp/net/kubed.el b/lisp/net/kubed.el index 2215716b863..86a173f0b8d 100644 --- a/lisp/net/kubed.el +++ b/lisp/net/kubed.el @@ -934,10 +934,13 @@ Optional argument DEFAULT is the minibuffer default argument." (message "Now using Kubernetes context `%s'." context) (kubed-update-all)) -(defun kubed-current-namespace () - "Return current Kubernetes namespace." - (car (process-lines kubed-kubectl-executable - "config" "view" "-o" "jsonpath={..namespace}"))) +(defun kubed-current-namespace (&optional context) + "Return current Kubernetes namespace for context CONTEXT." + (car (process-lines + kubed-kubectl-executable + "config" "view" "-o" + (format "jsonpath={.contexts[?(.name==\"%s\")].context.namespace}" + (or context (kubed-current-context)))))) ;;;###autoload (defun kubed-set-namespace (ns)