]> git.eshelyaron.com Git - kubed.git/commitdiff
Teach 'kubed-diff' about buffer-local contexts
authorEshel Yaron <me@eshelyaron.com>
Wed, 14 Aug 2024 19:13:04 +0000 (21:13 +0200)
committerEshel Yaron <me@eshelyaron.com>
Thu, 15 Aug 2024 07:08:15 +0000 (09:08 +0200)
* kubed.el (kubed-diff): Use buffer-local context and
handle prefix arg.
* kubed-transient.el (kubed-transient-diff): Add
"--context=" infix argument.

kubed-transient.el
kubed.el

index c63819a54ad2945315c9afe57780bfc89ce64341..829eedb6640f2e2757ace12f37913c82699286ea 100644 (file)
     ("-M" "Include managed fields" "--show-managed-fields")]
    ["Options"
     ("-f" "Definition file" "--filename="
-     :reader kubed-transient-read-resource-definition-file-name)]]
+     :reader kubed-transient-read-resource-definition-file-name)
+    ("-C" "Context" "--context="
+     :prompt "Context" :reader kubed-transient-read-context)]]
   (interactive)
   (transient-setup 'kubed-transient-diff nil nil
                    :scope '("diff")))
index 02aa2e2fb7ce54722eb7de08b77b319d64cbfc97..d1a40b6f8a440b03267e28060885933487470df6 100644 (file)
--- a/kubed.el
+++ b/kubed.el
@@ -2805,15 +2805,19 @@ the current context; non-nil INCLUDE-MANAGED (interactively, the prefix
 argument) says to include managed fields in the comparison."
   (interactive
    (let ((definition nil) (context nil) (include-managed nil))
-     (dolist (arg (when (and (fboundp 'transient-args)
-                             (fboundp 'kubed-transient-diff))
-                    (transient-args 'kubed-transient-diff)))
+     (dolist (arg (kubed-transient-args 'kubed-transient-diff))
        (cond
         ((string-match "--filename=\\(.+\\)" arg)
          (setq definition (match-string 1 arg)))
         ((string-match "--context=\\(.+\\)" arg)
          (setq context (match-string 1 arg)))
         ((equal "--show-managed-fields" arg) (setq include-managed t))))
+     (unless context
+       (setq context
+             (let ((cxt (kubed-local-context)))
+               (if (equal current-prefix-arg '(16))
+                   (kubed-read-context "Context" cxt)
+                 cxt))))
      (list (or definition (kubed-read-resource-definition-file-name))
            (or include-managed current-prefix-arg)
            context)))