diff --git a/docs/how-tos/usage.md b/docs/how-tos/usage.md index 826675a..c2402a4 100644 --- a/docs/how-tos/usage.md +++ b/docs/how-tos/usage.md @@ -108,6 +108,13 @@ Kele commands involving Kubernetes [contexts] center around the `s-k c` prefix ( Most context-related Kele functionality can also be done via [Embark] on any completion candidate in any context-related Kele command. +!!! tip + + If you have functions that need to run after switching to a new context in + order to use it, `kele-after-context-switch-hook` is available to use. This + can be useful for, say, re-authenticating with the new context before + interacting with it. + ### Managing proxy servers Kele allows for starting and stopping [HTTP diff --git a/kele.el b/kele.el index e92d71f..6b5bc3f 100644 --- a/kele.el +++ b/kele.el @@ -99,6 +99,9 @@ pods." :type 'integer :group 'kele) +(defvar kele-after-context-switch-hook nil + "Normal hook run after switching to a new context.") + (defvar kele--discovery-last-refresh-time nil "Timestamp of last successful poll of the discovery cache.") @@ -741,7 +744,8 @@ node `(elisp)Programmed Completion'." 'warning))) (interactive (list (completing-read "Context: " #'kele--contexts-complete))) (kele--with-progress (format "Switching to use context `%s'..." context) - (kele-kubectl-do "config" "use-context" context))) + (kele-kubectl-do "config" "use-context" context) + (run-hooks 'kele-after-context-switch-hook))) ;; TODO(#176): Update `kele--namespace-cache' (transient-define-suffix kele-context-rename (old-name new-name)