[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/kubed 003ecf531c 04/12: Teach rollout commands about bu
From: |
ELPA Syncer |
Subject: |
[elpa] externals/kubed 003ecf531c 04/12: Teach rollout commands about buffer-local contexts |
Date: |
Thu, 15 Aug 2024 12:58:28 -0400 (EDT) |
branch: externals/kubed
commit 003ecf531c6948ba3cbef9d58dac4552caa9d74b
Author: Eshel Yaron <me@eshelyaron.com>
Commit: Eshel Yaron <me@eshelyaron.com>
Teach rollout commands about buffer-local contexts
* kubed-transient.el (kubed-transient-rollout): Add
"--context" infix argument.
* kubed.el (kubed-restart-deployment)
(kubed-watch-deployment-status): Use local context and
namespace. Also add callback argument to 'watch' command.
---
kubed-transient.el | 4 +-
kubed.el | 117 ++++++++++++++++++++++++++++++++++++-----------------
2 files changed, 84 insertions(+), 37 deletions(-)
diff --git a/kubed-transient.el b/kubed-transient.el
index 1dcf918095..2b03ffb419 100644
--- a/kubed-transient.el
+++ b/kubed-transient.el
@@ -75,7 +75,9 @@
("!" "Command line" kubed-kubectl-command)]
["Options"
("-n" "Namespace" "--namespace="
- :prompt "Namespace" :reader kubed-transient-read-namespace)]]
+ :prompt "Namespace" :reader kubed-transient-read-namespace)
+ ("-C" "Context" "--context="
+ :prompt "Context" :reader kubed-transient-read-context)]]
(interactive)
(transient-setup 'kubed-transient-rollout nil nil
:scope '("rollout")))
diff --git a/kubed.el b/kubed.el
index d96fa8121f..558aeb29db 100644
--- a/kubed.el
+++ b/kubed.el
@@ -1865,35 +1865,53 @@ defaulting to the current namespace."
(message "Created Kubernetes job `%s'." name)))
;;;###autoload
-(defun kubed-watch-deployment-status (dep &optional context namespace)
+(defun kubed-watch-deployment-status (dep &optional context namespace cb)
"Show and update status of Kubernetes deployment DEP in a dedicate buffer.
Optional argument CONTEXT is the `kubectl' context to use, defaulting to
the current context; NAMESPACE is the namespace of DEP, defaulting to
-the current namespace."
+the current namespace. CB is an optional callback function to call with
+no arguments when the deployment ends.
+
+Interactively, prompt for DEP. With a prefix argument, prompt for
+NAMESPACE too. With a double prefix argument, also prompt for CONTEXT."
(interactive
- (let ((namespace (seq-some
- (lambda (arg)
- (when (string-match "--namespace=\\(.+\\)" arg)
- (match-string 1 arg)))
- (kubed-transient-args 'kubed-transient-rollout))))
- (list (kubed-read-deployment "Watch deployment status" nil nil nil
namespace)
- nil namespace)))
+ (let (context namespace)
+ (dolist (arg (kubed-transient-args 'kubed-transient-rollout))
+ (cond
+ ((string-match "--context=\\(.+\\)" arg)
+ (setq context (match-string 1 arg)))
+ ((string-match "--namespace=\\(.+\\)" arg)
+ (setq namespace (match-string 1 arg)))))
+ (unless context
+ (setq context
+ (let ((cxt (kubed-local-context)))
+ (if (equal current-prefix-arg '(16))
+ (kubed-read-context "Context" cxt)
+ cxt))))
+ (unless namespace
+ (setq namespace
+ (let ((cur (kubed-local-namespace context)))
+ (if current-prefix-arg
+ (kubed-read-namespace "Namespace" cur nil context)
+ cur))))
+ (list (kubed-read-deployment "Watch deployment status" nil nil
+ context namespace)
+ context namespace)))
(let ((buf (get-buffer-create "*kubed-deployment-status*"))
- (context (or context (kubed-current-context)))
- (namespace (or namespace (kubed-current-namespace context))))
+ (context (or context (kubed-local-context)))
+ (namespace (or namespace (kubed-local-namespace context))))
(with-current-buffer buf (erase-buffer))
(make-process
:name "*kubed-watch-deployment-status*"
:buffer buf
:command (list kubed-kubectl-program "rollout" "status"
"deployment" dep "-n" namespace "--context" context)
- :sentinel
- (lambda (_proc status)
- (when (member status
- '("finished\n" "exited abnormally with code 1\n"))
- (message "Deployment complete")
- (kubed-update "deployments" context namespace))))
+ :sentinel (when cb
+ (lambda (_proc status)
+ (when (member status '("finished\n"
+ "exited abnormally with code 1\n"))
+ (funcall cb)))))
(display-buffer buf)))
(defcustom kubed-restart-deployment-watch-status t
@@ -1903,26 +1921,53 @@ the current namespace."
;;;###autoload
(defun kubed-restart-deployment (dep &optional context namespace)
"Restart Kubernetes deployment DEP in namespace NAMESPACE via CONTEXT.
-If NAMESPACE is nil or omitted, it defaults to the current namespace."
+
+Optional argument CONTEXT is the `kubectl' context to use, defaulting to
+the current context; NAMESPACE is the namespace of DEP, defaulting to
+the current namespace. CB is an optional callback function to call with
+no arguments when the deployment ends.
+
+Interactively, prompt for DEP. With a prefix argument, prompt for
+NAMESPACE too. With a double prefix argument, also prompt for CONTEXT."
(interactive
- (let ((namespace (seq-some
- (lambda (arg)
- (when (string-match "--namespace=\\(.+\\)" arg)
- (match-string 1 arg)))
- (kubed-transient-args 'kubed-transient-rollout))))
- (list (kubed-read-deployment "Restart deployment" nil nil nil namespace)
- nil namespace)))
- (unless (zerop
- (apply #'call-process
- kubed-kubectl-program nil nil nil
- "rollout" "restart" "deployment" dep
- (append
- (when namespace (list "-n" namespace))
- (when context (list "--context" context)))))
- (user-error "Failed to restart Kubernetes deployment `%s'" dep))
- (message "Restarting Kubernetes deployment `%s'." dep)
- (when kubed-restart-deployment-watch-status
- (kubed-watch-deployment-status dep context namespace)))
+ (let (context namespace)
+ (dolist (arg (kubed-transient-args 'kubed-transient-rollout))
+ (cond
+ ((string-match "--context=\\(.+\\)" arg)
+ (setq context (match-string 1 arg)))
+ ((string-match "--namespace=\\(.+\\)" arg)
+ (setq namespace (match-string 1 arg)))))
+ (unless context
+ (setq context
+ (let ((cxt (kubed-local-context)))
+ (if (equal current-prefix-arg '(16))
+ (kubed-read-context "Context" cxt)
+ cxt))))
+ (unless namespace
+ (setq namespace
+ (let ((cur (kubed-local-namespace context)))
+ (if current-prefix-arg
+ (kubed-read-namespace "Namespace" cur nil context)
+ cur))))
+ (list (kubed-read-deployment "Restart deployment" nil nil
+ context namespace)
+ context namespace)))
+ (let ((context (or context (kubed-local-context)))
+ (namespace (or namespace (kubed-local-namespace context))))
+ (unless (zerop
+ (apply #'call-process
+ kubed-kubectl-program nil nil nil
+ "rollout" "restart" "deployment" dep
+ (append
+ (when namespace (list "-n" namespace))
+ (when context (list "--context" context)))))
+ (user-error "Failed to restart Kubernetes deployment `%s'" dep))
+ (message "Restarting Kubernetes deployment `%s'." dep)
+ (when kubed-restart-deployment-watch-status
+ (kubed-watch-deployment-status
+ dep context namespace
+ (lambda ()
+ (kubed-update "deployments" context namespace))))))
;;;###autoload (autoload 'kubed-display-deployment "kubed" nil t)
;;;###autoload (autoload 'kubed-edit-deployment "kubed" nil t)
- [elpa] externals/kubed updated (cca5f42891 -> 0863c58f1a), ELPA Syncer, 2024/08/15
- [elpa] externals/kubed a46344f2b0 01/12: Use buffer-local context in 'kubed-list-*' commands, ELPA Syncer, 2024/08/15
- [elpa] externals/kubed cdeb94ea56 03/12: ; Use local context as default in some prompts, ELPA Syncer, 2024/08/15
- [elpa] externals/kubed a1c741360a 08/12: Teach 'kubed-exec' about buffer-local contexts, ELPA Syncer, 2024/08/15
- [elpa] externals/kubed 003ecf531c 04/12: Teach rollout commands about buffer-local contexts,
ELPA Syncer <=
- [elpa] externals/kubed 6c6886bdcd 11/12: New user option 'kubed-default-context-and-namespace', ELPA Syncer, 2024/08/15
- [elpa] externals/kubed 72593fb84f 02/12: ; (kubed-current-namespace): Use buffer-local context., ELPA Syncer, 2024/08/15
- [elpa] externals/kubed ae4ba0de59 10/12: Teach additional commands about buffer-local contexts, ELPA Syncer, 2024/08/15
- [elpa] externals/kubed 5b2f47142a 06/12: Teach 'kubed-patch' about buffer-local contexts, ELPA Syncer, 2024/08/15
- [elpa] externals/kubed e545b90c54 05/12: ; (kubed-resource-names): Default to local context and namespace, ELPA Syncer, 2024/08/15
- [elpa] externals/kubed 5954f4f339 09/12: ; Fix regex matching multi-hop Tramp file names, ELPA Syncer, 2024/08/15
- [elpa] externals/kubed 5cb64af942 07/12: Teach 'kubed-diff' about buffer-local contexts, ELPA Syncer, 2024/08/15
- [elpa] externals/kubed 0863c58f1a 12/12: ; Update NEWS.org and bump version to 0.3.2, ELPA Syncer, 2024/08/15