Add kubectl.el
This commit is contained in:
parent
dbf65caabe
commit
2397203e80
53
emacs/.emacs.d/config/init-kubernetes.el
Normal file
53
emacs/.emacs.d/config/init-kubernetes.el
Normal file
@ -0,0 +1,53 @@
|
||||
;; -*- lexical-binding: t; -*-
|
||||
|
||||
(use-package kubectl
|
||||
:straight (:host github :repo "jypma/kubectl")
|
||||
:if (executable-find "kubectl")
|
||||
:config
|
||||
(setq kubectl--kubectl (executable-find "kubectl"))
|
||||
(defun kubectl-choose-context (context)
|
||||
"Select a new context interactively"
|
||||
(interactive (list (completing-read "Context: " (kubectl--context-names) nil t)))
|
||||
(setq kubectl--context context)
|
||||
(make-process :name "kubectx" :command (list (executable-find "kubectx") context))
|
||||
(call-interactively 'kubectl-choose-namespace))
|
||||
(defun kubectl-choose-namespace (namespace)
|
||||
"Select a new namespace interactively"
|
||||
(interactive (list (completing-read "Namespace: " (kubectl--namespace-names) nil t)))
|
||||
(setq kubectl--namespace namespace)
|
||||
(make-process :name "kubens" :command (list (executable-find "kubens") namespace))
|
||||
(when kubectl-pods-mode
|
||||
(call-interactively #'kubectl-pods-refresh)))
|
||||
(general-def kubectl-log-mode-map
|
||||
"C-c k" #'kubectl--log-kill-process)
|
||||
(general-def 'normal kubectl-log-mode-map
|
||||
"q" #'bury-buffer)
|
||||
(general-def 'normal kubectl-pods-mode-map
|
||||
"c" #'kubectl-choose-context
|
||||
"s" #'kubectl-pods-choose-namespace
|
||||
"gr" #'kubectl-pods-refresh
|
||||
"gl" #'kubectl--pods-log
|
||||
"t" #'kubectl--pods-term
|
||||
"r" #'kubectl-pods-run
|
||||
"i" #'kubectl--pods-inspect
|
||||
"d" #'kubectl--pods-dired)
|
||||
(general-def 'normal kubectl-deployments-mode-map
|
||||
"c" #'kubectl-choose-context
|
||||
"s" #'kubectl-choose-namespace
|
||||
"gr" #'kubectl--deployments-refresh
|
||||
"o" #'kubectl--deployments-open
|
||||
"RET" #'kubectl--deployments-open
|
||||
"i" #'kubectl--deployments-inspect)
|
||||
(general-def 'normal kubectl-statefulsets-mode-map
|
||||
"c" #'kubectl-choose-context
|
||||
"s" #'kubectl-choose-namespace
|
||||
"gr" #'kubectl--statefulsets-refresh
|
||||
"o" #'kubectl--statefulsets-open
|
||||
"RET" #'kubectl--statefulsets-open
|
||||
"i" #'kubectl--statefulsets-inspect)
|
||||
:commands (kubectl-choose-context
|
||||
kubectl-choose-namespace
|
||||
kubectl-deployments
|
||||
kubectl-statefulsets))
|
||||
|
||||
(provide 'init-kubernetes)
|
@ -86,6 +86,7 @@
|
||||
(require 'init-prodigy)
|
||||
(require 'init-direnv)
|
||||
(require 'init-email)
|
||||
(require 'init-kubernetes)
|
||||
|
||||
;; Load the custom file
|
||||
(when (file-exists-p custom-file)
|
||||
|
Loading…
Reference in New Issue
Block a user