[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/kubed 9aa3c97dcc 14/70: Extend resource name reading fu
From: |
ELPA Syncer |
Subject: |
[elpa] externals/kubed 9aa3c97dcc 14/70: Extend resource name reading functions with namespace arg |
Date: |
Tue, 6 Aug 2024 06:58:26 -0400 (EDT) |
branch: externals/kubed
commit 9aa3c97dcc1952fc15659893a272b5a54953e670
Author: Eshel Yaron <me@eshelyaron.com>
Commit: Eshel Yaron <me@eshelyaron.com>
Extend resource name reading functions with namespace arg
* kubed.el (kubed-define-resource): Add optional namespace
argument to 'kubed-read-RESOURCE' functions.
(kubed-attach, kubed-exec): Use it when reading name of pod
in another namespace.
---
kubed.el | 59 ++++++++++++++++++++++++++++++++++++++++++-----------------
1 file changed, 42 insertions(+), 17 deletions(-)
diff --git a/kubed.el b/kubed.el
index 44319e7e9f..ae5a260940 100644
--- a/kubed.el
+++ b/kubed.el
@@ -392,7 +392,8 @@ Other keyword arguments that go between PROPERTIES and
COMMANDS are:
'face
'completions-annotations))))
,plrl-var)))
- (defun ,read-fun (prompt &optional default multi)
+ (defun ,read-fun (prompt &optional default multi
+ . ,(when namespaced '(k8sns)))
,(format "Prompt with PROMPT for a Kubernetes %S name.
Optional argument DEFAULT is the minibuffer default argument.
@@ -404,16 +405,44 @@ of %S, instead of just one." resource plrl-var)
(funcall
(if multi #'completing-read-multiple #'completing-read)
(format-prompt prompt default)
- (lambda (s p a)
- (if (eq a 'metadata)
- '(metadata
- (category . ,(intern (format "kubernetes-%S" resource)))
- ,@(when properties
- `((affixation-function . ,affx-fun))))
- (while (and (process-live-p ,proc-var)
- (null ,list-var))
- (accept-process-output ,proc-var 1))
- (complete-with-action a ,list-var s p)))
+ ,(if namespaced
+ `(if (or (null k8sns) (string= k8sns
(kubed-current-namespace)))
+ ;; Current namespace.
+ (lambda (s p a)
+ (if (eq a 'metadata)
+ '(metadata
+ (category . ,(intern (format "kubernetes-%S"
resource)))
+ ,@(when properties
+ `((affixation-function . ,affx-fun))))
+ (while (and (process-live-p ,proc-var)
+ (null ,list-var))
+ (accept-process-output ,proc-var 1))
+ (complete-with-action a ,list-var s p)))
+ ;; Different namespace.
+ (let ((table 'unset))
+ (lambda (s p a)
+ (if (eq a 'metadata)
+ '(metadata
+ (category . ,(intern (format "kubernetes-%S"
resource))))
+ (when (eq table 'unset)
+ (setq table
+ (process-lines
+ kubed-kubectl-program
+ "get" ,(format "%S" plrl-var)
+ "-o" "custom-columns=NAME:.metadata.name"
+ "--no-headers"
+ "-n" k8sns)))
+ (complete-with-action a table s p)))))
+ `(lambda (s p a)
+ (if (eq a 'metadata)
+ '(metadata
+ (category . ,(intern (format "kubernetes-%S"
resource)))
+ ,@(when properties
+ `((affixation-function . ,affx-fun))))
+ (while (and (process-live-p ,proc-var)
+ (null ,list-var))
+ (accept-process-output ,proc-var 1))
+ (complete-with-action a ,list-var s p))))
nil 'confirm nil ',hist-var default)) )
(defun ,read-crm (prompt &optional default)
@@ -1723,9 +1752,7 @@ with \\[universal-argument] \\[universal-argument]; and
TTY is t unless\
(p (car p-s))
(s (cadr p-s)))
(list p (kubed-read-container p "Container" t s) s stdin tty))
- ;; FIXME: When namespace is set from transient prefix, read pod
- ;; name in that namespace instead.
- (let* ((p (kubed-read-pod "Attach to pod"))
+ (let* ((p (kubed-read-pod "Attach to pod" nil nil namespace))
(c (kubed-read-container p "Container" t namespace)))
(list p c namespace stdin tty)))))
(pop-to-buffer
@@ -1805,9 +1832,7 @@ with \\[universal-argument] \\[universal-argument]; and
TTY is t unless\
command (car args)
args (cdr args)))
(list p command c s stdin tty args))
- ;; FIXME: Similarly to `kubed-attach', when namespace is set from
- ;; transient prefix, read pod name in that namespace instead.
- (let* ((p (kubed-read-pod "Execute command in pod"))
+ (let* ((p (kubed-read-pod "Execute command in pod" nil nil namespace))
(c (kubed-read-container p "Container" t namespace)))
(unless command
(setq args (split-string-and-unquote
- [elpa] externals/kubed 8463c1bb8a 34/70: Ensure SPC is self-inserting when reading kubectl command line, (continued)
- [elpa] externals/kubed 8463c1bb8a 34/70: Ensure SPC is self-inserting when reading kubectl command line, ELPA Syncer, 2024/08/06
- [elpa] externals/kubed f6ebd33c16 35/70: Use multi-column layout for transient menus, ELPA Syncer, 2024/08/06
- [elpa] externals/kubed 603a4d413a 38/70: Enhance 'kubed-list-read-filter', ELPA Syncer, 2024/08/06
- [elpa] externals/kubed d73c4fac3f 41/70: (kubed-list-read-filter-map): Bind 'completion-help-at-point'., ELPA Syncer, 2024/08/06
- [elpa] externals/kubed ed6d13e196 57/70: New command 'kubed-display-resource-jump-to-list', ELPA Syncer, 2024/08/06
- [elpa] externals/kubed 977ac8d324 61/70: Major cleanup: simplify and extend resource lists, ELPA Syncer, 2024/08/06
- [elpa] externals/kubed 51cdf1d100 64/70: ; Update copyright notices for GNU ELPA, ELPA Syncer, 2024/08/06
- [elpa] externals/kubed 018d529c3b 33/70: New command 'kubed-transient-rollout', ELPA Syncer, 2024/08/06
- [elpa] externals/kubed 1a6d51981c 02/70: ; * README.md (Getting Started): Fix typo, ELPA Syncer, 2024/08/06
- [elpa] externals/kubed b7227ed155 12/70: ; README.md: Add figure showing pods context menu., ELPA Syncer, 2024/08/06
- [elpa] externals/kubed 9aa3c97dcc 14/70: Extend resource name reading functions with namespace arg,
ELPA Syncer <=
- [elpa] externals/kubed 1047609241 26/70: * kubed.texi (Extending Kubed): Populate., ELPA Syncer, 2024/08/06
- [elpa] externals/kubed 667ccdb4a2 27/70: New commands for creating jobs from cronjobs, ELPA Syncer, 2024/08/06
- [elpa] externals/kubed 144e0cf167 32/70: New command 'kubed-watch-deployment-status', ELPA Syncer, 2024/08/06
- [elpa] externals/kubed bd3ebf3827 37/70: New command 'kubed-list-set-filter' in list buffers, ELPA Syncer, 2024/08/06
- [elpa] externals/kubed 2f062f5175 44/70: Document a couple more 'tabulated-list-mode' commands, ELPA Syncer, 2024/08/06
- [elpa] externals/kubed 83e71ecb32 42/70: New commands for table navigation, ELPA Syncer, 2024/08/06
- [elpa] externals/kubed 6c8dabc369 47/70: New user option 'kubed-list-filter-operator-alist', ELPA Syncer, 2024/08/06
- [elpa] externals/kubed bccc588b20 39/70: ; * kubed.el (kubed-list-read-filter): Fix typo., ELPA Syncer, 2024/08/06
- [elpa] externals/kubed 7c75a19dd4 48/70: (List Filter): Document 'kubed-list-filter-operator-alist', ELPA Syncer, 2024/08/06
- [elpa] externals/kubed 7c46d70a61 49/70: Update NEWS.org and bump version to 0.2.0, ELPA Syncer, 2024/08/06