From 2aa4a6bc926e5f7e7eb94c90189382502ff26e83 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Fri, 30 Aug 2019 10:34:58 -0400 Subject: [PATCH] helm-v3: Dynamic completion for "helm repo" and "helm plugin" (#6263) * Add dynamic completion for 'helm repo remove' Signed-off-by: Marc Khouzam * fix: --home flag has been removed Signed-off-by: Marc Khouzam * Dynamic completion for 'helm plugin remove/update' Signed-off-by: Marc Khouzam * Add returns for consitency Signed-off-by: Marc Khouzam --- cmd/helm/root.go | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/cmd/helm/root.go b/cmd/helm/root.go index 351045f68..004701725 100644 --- a/cmd/helm/root.go +++ b/cmd/helm/root.go @@ -28,7 +28,7 @@ import ( const ( bashCompletionFunc = ` -__helm_override_flag_list=(--kubeconfig --kube-context --home --namespace -n) +__helm_override_flag_list=(--kubeconfig --kube-context --namespace -n) __helm_override_flags() { local ${__helm_override_flag_list[*]##*-} two_word_of of var @@ -65,6 +65,22 @@ __helm_list_releases() COMPREPLY=( $( compgen -W "${out[*]}" -- "$cur" ) ) fi } +__helm_list_repos() +{ + __helm_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}" + local out + if out=$(helm repo list | 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 + if out=$(helm plugin list | tail +2 | cut -f1 2>/dev/null); then + COMPREPLY=( $( compgen -W "${out[*]}" -- "$cur" ) ) + fi +} __helm_custom_func() { __helm_debug "${FUNCNAME[0]}: last_command is $last_command" @@ -73,7 +89,15 @@ __helm_custom_func() helm_upgrade | helm_rollback | helm_get_*) __helm_list_releases return - ;; + ;; + helm_repo_remove) + __helm_list_repos + return + ;; + helm_plugin_remove | helm_plugin_update) + __helm_list_plugins + return + ;; *) ;; esac