From f95342b1b57297b6859e83c021f3d7582681c231 Mon Sep 17 00:00:00 2001 From: Daniel Lipovetsky Date: Wed, 16 Dec 2020 12:18:26 -0800 Subject: [PATCH] Fix "list" shell completion to prune duplicate release names By definition, the "list" shell completion should list all releases, no matter their status. Previously, if a release had multiple versions, the completion would list it more than once. This change prunes duplicates from the completion. Signed-off-by: Daniel Lipovetsky --- cmd/helm/list.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/helm/list.go b/cmd/helm/list.go index b71278c7c..e9ac5112c 100644 --- a/cmd/helm/list.go +++ b/cmd/helm/list.go @@ -209,8 +209,12 @@ func compListReleases(toComplete string, cfg *action.Configuration) ([]string, c } var choices []string + uniqueNames := map[string]bool{} for _, res := range results { - choices = append(choices, res.Name) + if ok := uniqueNames[res.Name]; !ok { + uniqueNames[res.Name] = true + choices = append(choices, res.Name) + } } return choices, cobra.ShellCompDirectiveNoFileComp