From: Eshel Yaron Date: Wed, 24 Jul 2024 06:35:48 +0000 (+0200) Subject: kubed.el: Add per-resource prefix keymap X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=960760a171968a1c9d30102a91d9e23ac40e90d3;p=emacs.git kubed.el: Add per-resource prefix keymap --- diff --git a/lisp/net/kubed.el b/lisp/net/kubed.el index b3ac36e4bbd..080e37e0cc6 100644 --- a/lisp/net/kubed.el +++ b/lisp/net/kubed.el @@ -182,11 +182,12 @@ namespaceless resource type, put `:namespaced nil' before COMMANDS: (out-name (format " *kubed-get-%Ss*" resource)) (err-name (format " *kubed-get-%Ss-stderr*" resource)) (dlt-errb (format " *kubed-%Ss-execute-stderr*" resource)) - (cmd-name (intern (format "kubed-display-%S" resource))) + (dsp-name (intern (format "kubed-display-%S" resource))) (edt-name (intern (format "kubed-edit-%S" resource))) (dlt-name (intern (format "kubed-delete-%Ss" resource))) (mod-name (intern (format "kubed-%Ss-mode" resource))) (crt-name (intern (format "kubed-create-%S" resource))) + (map-name (intern (format "kubed-%S-prefix-map" resource))) (crt-spec nil) (namespaced t) (keyword nil)) @@ -420,14 +421,14 @@ Optional argument DEFAULT is the minibuffer default argument." resource) (if multi split (car split))))) ,(if namespaced - `(defun ,cmd-name (,resource &optional k8sns) + `(defun ,dsp-name (,resource &optional k8sns) ,(format "Display Kubernetes %S %s." resource (upcase (symbol-name resource))) (interactive (if kubed-all-namespaces-mode (,read-nms "Display") (list (,read-fun "Display")))) (display-buffer (,desc-fun ,resource k8sns))) - `(defun ,cmd-name (,resource) + `(defun ,dsp-name (,resource) ,(format "Display Kubernetes %S %s." resource (upcase (symbol-name resource))) (interactive (list (,read-fun "Display"))) @@ -785,7 +786,17 @@ Optional argument DEFAULT is the minibuffer default argument." resource) ,(format "List Kubernetes %Ss." resource) (interactive) (,sure-fun) - (pop-to-buffer (,buff-fun ,list-var)))))) + (pop-to-buffer (,buff-fun ,list-var))) + + (defvar-keymap ,map-name + :doc ,(format "Prefix keymap for Kubed %s commands." + (symbol-name resource)) + :prefix ',map-name + "l" #',list-cmd + "c" #',crt-name + "e" #',edt-name + "d" #',dlt-name + "g" #',dsp-name)))) (defvar tramp-kubernetes-namespace) @@ -794,6 +805,7 @@ Optional argument DEFAULT is the minibuffer default argument." resource) ;;;###autoload (autoload 'kubed-delete-pods "kubed" nil t) ;;;###autoload (autoload 'kubed-list-pods "kubed" nil t) ;;;###autoload (autoload 'kubed-create-pod "kubed" nil t) +;;;###autoload (autoload 'kubed-pod-prefix-map "kubed" nil t 'keymap) (kubed-define-resource pod ((phase ".status.phase" 10) (starttime ".status.startTime" 20)) (dired "C-d" "Start Dired in home directory of first container of" @@ -823,6 +835,7 @@ Optional argument DEFAULT is the minibuffer default argument." resource) ;;;###autoload (autoload 'kubed-delete-namespaces "kubed" nil t) ;;;###autoload (autoload 'kubed-list-namespaces "kubed" nil t) ;;;###autoload (autoload 'kubed-create-namespace "kubed" nil t) +;;;###autoload (autoload 'kubed-namespace-prefix-map "kubed" nil t 'keymap) (kubed-define-resource namespace ((phase ".status.phase" 10) (creationtimestamp ".metadata.creationTimestamp" 20)) @@ -853,6 +866,7 @@ Optional argument DEFAULT is the minibuffer default argument." resource) ;;;###autoload (autoload 'kubed-delete-persistentvolumes "kubed" nil t) ;;;###autoload (autoload 'kubed-list-persistentvolumes "kubed" nil t) ;;;###autoload (autoload 'kubed-create-persistentvolume "kubed" nil t) +;;;###autoload (autoload 'kubed-persistentvolume-prefix-map "kubed" nil t 'keymap) (kubed-define-resource persistentvolume () :namespaced nil) ;;;###autoload (autoload 'kubed-display-service "kubed" nil t) @@ -860,6 +874,7 @@ Optional argument DEFAULT is the minibuffer default argument." resource) ;;;###autoload (autoload 'kubed-delete-services "kubed" nil t) ;;;###autoload (autoload 'kubed-list-services "kubed" nil t) ;;;###autoload (autoload 'kubed-create-service "kubed" nil t) +;;;###autoload (autoload 'kubed-service-prefix-map "kubed" nil t 'keymap) (kubed-define-resource service) ;;;###autoload (autoload 'kubed-display-secret "kubed" nil t) @@ -867,6 +882,7 @@ Optional argument DEFAULT is the minibuffer default argument." resource) ;;;###autoload (autoload 'kubed-delete-secrets "kubed" nil t) ;;;###autoload (autoload 'kubed-list-secrets "kubed" nil t) ;;;###autoload (autoload 'kubed-create-secret "kubed" nil t) +;;;###autoload (autoload 'kubed-secret-prefix-map "kubed" nil t 'keymap) (kubed-define-resource secret ((type ".type" 32) (creationtimestamp ".metadata.creationTimestamp" 20))) @@ -875,6 +891,7 @@ Optional argument DEFAULT is the minibuffer default argument." resource) ;;;###autoload (autoload 'kubed-delete-jobs "kubed" nil t) ;;;###autoload (autoload 'kubed-list-jobs "kubed" nil t) ;;;###autoload (autoload 'kubed-create-job "kubed" nil t) +;;;###autoload (autoload 'kubed-job-prefix-map "kubed" nil t 'keymap) (kubed-define-resource job ((status ".status.conditions[0].type" 10) (starttime ".status.startTime" 20))) @@ -883,6 +900,7 @@ Optional argument DEFAULT is the minibuffer default argument." resource) ;;;###autoload (autoload 'kubed-delete-deployments "kubed" nil t) ;;;###autoload (autoload 'kubed-list-deployments "kubed" nil t) ;;;###autoload (autoload 'kubed-create-deployment "kubed" nil t) +;;;###autoload (autoload 'kubed-deployment-prefix-map "kubed" nil t 'keymap) (kubed-define-resource deployment ((reps ".status.replicas" 4 (lambda (l r) (< (string-to-number l) (string-to-number r))) @@ -939,6 +957,7 @@ optional command to run in the images." ;;;###autoload (autoload 'kubed-delete-replicasets "kubed" nil t) ;;;###autoload (autoload 'kubed-list-replicasets "kubed" nil t) ;;;###autoload (autoload 'kubed-create-replicaset "kubed" nil t) +;;;###autoload (autoload 'kubed-replicateset-prefix-map "kubed" nil t 'keymap) (kubed-define-resource replicaset ((reps ".status.replicas" 4 (lambda (l r) (< (string-to-number l) (string-to-number r))) @@ -952,6 +971,7 @@ optional command to run in the images." ;;;###autoload (autoload 'kubed-delete-statefulsets "kubed" nil t) ;;;###autoload (autoload 'kubed-list-statefulsets "kubed" nil t) ;;;###autoload (autoload 'kubed-create-statefulset "kubed" nil t) +;;;###autoload (autoload 'kubed-statefulset-prefix-map "kubed" nil t 'keymap) (kubed-define-resource statefulset ((reps ".status.replicas" 4 (lambda (l r) (< (string-to-number l) (string-to-number r)))