From ecb218884a871d292cf507571357834b6498babb Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Wed, 24 Jul 2024 07:15:45 +0200 Subject: [PATCH] (kubed-current-namespace): Fix handling of multiple contexts --- lisp/net/kubed.el | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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) -- 2.39.2