From be82cb240c11a5b6ce8dce7314295476308c7e8a Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Fri, 17 May 2019 22:52:23 -0400 Subject: [PATCH] Add a filter to the helm list call for completion Signed-off-by: Marc Khouzam --- cmd/helm/helm.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cmd/helm/helm.go b/cmd/helm/helm.go index b3f16fb7f..8d4652984 100644 --- a/cmd/helm/helm.go +++ b/cmd/helm/helm.go @@ -71,14 +71,18 @@ __helm_override_flags() __helm_list_releases() { - local out - if out=$(helm list $(__helm_override_flags) -a -q 2>/dev/null); then + __helm_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}" + local out filter + # Use ^ to map from the start of the release name + filter="^${words[c]}" + if out=$(helm list $(__helm_override_flags) -a -q ${filter} 2>/dev/null); then COMPREPLY=( $( compgen -W "${out[*]}" -- "$cur" ) ) fi } __helm_custom_func() { + __helm_debug "${FUNCNAME[0]}: c is $c words[@] is ${words[@]}" case ${last_command} in helm_delete | helm_history | helm_status | helm_test |\ helm_upgrade | helm_rollback | helm_get_*)