- `kubed-update-RESROURCEs': update and repopulate RESOURCEs list.
- `kubed-create-RESROURCE': create a RESOURCE from a YAML or a JSON file.
+This macro also defines a prefix keymap, `kubed-RESOURCE-prefix-map',
+with bindings for the above commands.
+
PROPERTIES is a list of elements (PROPERTY JSON-PATH WIDTH SORT . ATTRS)
that specify properties of RESOURCEs. PROPERTY is the name of the
property, as a symbol; JSON-PATH is a JSONPath expression that evaluates
(kubed-define-resource global-thingy (PROP1 PROP2 ...) :namespaced nil
CMD1
CMD2
- ...)"
+ ...)
+
+Other keyword arguments that go between PROPERTIES and COMMANDS are:
+
+- `:create (ARGLIST DOCSTRING INTERACTIVE BODY...)': specialize the
+ resource creation command, `kubed-create-RESROURCE'. ARGLIST,
+ DOCSTRING, INTERACTIVE and BODY have the same meaning as in `defun'.
+- `:prefix (KEY DEFINITION...)': additional keybinding for the prefix
+ keymap `kubed-RESOURCE-prefix-map'."
(declare (indent 2))
(let ((hist-var (intern (format "kubed-%S-history" resource)))
(list-var (intern (format "kubed-%Ss" resource)))
(crt-name (intern (format "kubed-create-%S" resource)))
(map-name (intern (format "kubed-%S-prefix-map" resource)))
(crt-spec nil)
+ (prf-keys nil)
(namespaced t)
(keyword nil))
(cond
((eq keyword :namespaced) (setq namespaced (pop commands)))
((eq keyword :create) (setq crt-spec (pop commands)))
+ ((eq keyword :prefix) (setq prf-keys (pop commands)))
;; FIXME: Add error for unknown keywords.
(t (pop commands))))
"c" #',crt-name
"e" #',edt-name
"d" #',dlt-name
- "g" #',dsp-name))))
+ "g" #',dsp-name
+ "u" #',updt-cmd
+ ,@prf-keys))))
(defvar tramp-kubernetes-namespace)
;;;###autoload (autoload 'kubed-pod-prefix-map "kubed" nil t 'keymap)
(kubed-define-resource pod
((phase ".status.phase" 10) (starttime ".status.startTime" 20))
+ :prefix ("L" #'kubed-logs
+ "F" #'kubed-forward-port-to-pod)
(dired "C-d" "Start Dired in home directory of first container of"
;; FIXME: This doesn't really make sense for other namespaces,
;; we create the Dired buffer using the correct namespace, but
((phase ".status.phase" 10)
(creationtimestamp ".metadata.creationTimestamp" 20))
:namespaced nil
+ :prefix ("S" #'kubed-set-namespace)
:create
((name) "Create Kubernetes namespace with name NAME."
(interactive (list (read-string "Create namespace with name: ")))
(defun kubed-create (definition &optional kind)
"Create Kubernetes resource of kind KIND with definition DEFINITION."
(interactive
- (list (kubed-read-resource-definition-file-name)))
+ (list (or (and (fboundp 'transient-args)
+ (fboundp 'kubed-transient-create-deployment)
+ (seq-some
+ (lambda (arg)
+ (when (string-match "--filename=\\(.+\\)" arg)
+ (match-string 1 arg)))
+ (transient-args 'kubed-transient-create)))
+ (kubed-read-resource-definition-file-name))))
(let ((kind (or kind "resource")))
(message "Creating Kubernetes %s with definition `%s'..." kind definition)
(message "Creating Kubernetes %s with definition `%s'... Done. New %s name is `%s'."
(format-prompt prompt default) nil nil nil nil
'kubed-container-images-history default))
+;;;###autoload (autoload 'kubed-prefix-map "kubed" nil t 'keymap)
+(defvar-keymap kubed-prefix-map
+ :doc "Prefix keymap for Kubed commands."
+ :prefix 'kubed-prefix-map
+ "p" 'kubed-pod-prefix-map
+ "N" 'kubed-namespace-prefix-map
+ "s" 'kubed-service-prefix-map
+ "S" 'kubed-secret-prefix-map
+ "j" 'kubed-job-prefix-map
+ "d" 'kubed-deployment-prefix-map
+ "C" #'kubed-use-context
+ "A" #'kubed-all-namespaces-mode
+ "+" #'kubed-create)
+
(provide 'kubed)
;;; kubed.el ends here