From f3b9cf3beae51eec4bf1f0ac6342d6ed6da3c996 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Sun, 2 Oct 2022 23:25:20 +0200 Subject: [PATCH] feat(kubeadm): add auto-completion plugin --- plugins/kubeadm/README.md | 10 ++++++++++ plugins/kubeadm/kubeadm.plugin.zsh | 11 +++++++++++ 2 files changed, 21 insertions(+) create mode 100644 plugins/kubeadm/README.md create mode 100644 plugins/kubeadm/kubeadm.plugin.zsh diff --git a/plugins/kubeadm/README.md b/plugins/kubeadm/README.md new file mode 100644 index 000000000..f8a1b7086 --- /dev/null +++ b/plugins/kubeadm/README.md @@ -0,0 +1,10 @@ +# kubeadm plugin + +This plugin adds completion for the [kubernetes cluster creator](https://kubernetes.io/docs/reference/setup-tools/kubeadm/). +Kubeadm is a tool built to provide kubeadm init and kubeadm join as best-practice "fast paths" for creating Kubernetes clusters. + +To use it, add `kubeadm` to the plugins array in your zshrc file: + +```zsh +plugins=(... kubeadm) +``` diff --git a/plugins/kubeadm/kubeadm.plugin.zsh b/plugins/kubeadm/kubeadm.plugin.zsh new file mode 100644 index 000000000..fa3fc9331 --- /dev/null +++ b/plugins/kubeadm/kubeadm.plugin.zsh @@ -0,0 +1,11 @@ +if (( $+commands[kubeadm] )); then + # If the completion file does not exist, generate it and then source it + # Otherwise, source it and regenerate in the background + if [[ ! -f "$ZSH_CACHE_DIR/completions/_kubeadm" ]]; then + kubeadm completion zsh | tee "$ZSH_CACHE_DIR/completions/_kubeadm" >/dev/null + source "$ZSH_CACHE_DIR/completions/_kubeadm" + else + source "$ZSH_CACHE_DIR/completions/_kubeadm" + kubeadm completion zsh | tee "$ZSH_CACHE_DIR/completions/_kubeadm" >/dev/null &| + fi +fi