From 3ed073b2e0c37dd5c994562d6fe8e04b5f3609eb Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Tue, 3 Sep 2019 10:01:47 -0400 Subject: [PATCH] v2: Dynamic completion for "helm repo" and "helm plugin" (#6265) * feat(helm): Completion for helm repo remove Signed-off-by: Marc Khouzam * feat(helm): Complete for helm plugin remove/update helm repo remove (will select from the names of configured repos) helm plugin remove (will select from names of installed plugins) helm plugin update (will select from names of installed plugins) Signed-off-by: Marc Khouzam * feat(helm): Completion for helm repo update Signed-off-by: Marc Khouzam --- cmd/helm/helm.go | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/cmd/helm/helm.go b/cmd/helm/helm.go index 2f394968f..20742836d 100644 --- a/cmd/helm/helm.go +++ b/cmd/helm/helm.go @@ -41,7 +41,7 @@ import ( const ( bashCompletionFunc = ` -__helm_override_flag_list=(--kubeconfig --kube-context --host --tiller-namespace) +__helm_override_flag_list=(--kubeconfig --kube-context --host --tiller-namespace --home) __helm_override_flags() { local ${__helm_override_flag_list[*]##*-} two_word_of of var @@ -80,6 +80,28 @@ __helm_list_releases() fi } +__helm_list_repos() +{ + __helm_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}" + local out oflags + oflags=$(__helm_override_flags) + __helm_debug "${FUNCNAME[0]}: __helm_override_flags are ${oflags}" + if out=$(helm repo list ${oflags} | tail +2 | cut -f1 2>/dev/null); then + COMPREPLY=( $( compgen -W "${out[*]}" -- "$cur" ) ) + fi +} + +__helm_list_plugins() +{ + __helm_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}" + local out oflags + oflags=$(__helm_override_flags) + __helm_debug "${FUNCNAME[0]}: __helm_override_flags are ${oflags}" + if out=$(helm plugin list ${oflags} | tail +2 | cut -f1 2>/dev/null); then + COMPREPLY=( $( compgen -W "${out[*]}" -- "$cur" ) ) + fi +} + __helm_custom_func() { __helm_debug "${FUNCNAME[0]}: c is $c words[@] is ${words[@]}" @@ -89,6 +111,14 @@ __helm_custom_func() __helm_list_releases return ;; + helm_repo_remove | helm_repo_update) + __helm_list_repos + return + ;; + helm_plugin_remove | helm_plugin_update) + __helm_list_plugins + return + ;; *) ;; esac