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 <dlipovetsky@d2iq.com>
pull/9135/head
Daniel Lipovetsky 5 years ago
parent 81345a0bb7
commit f95342b1b5
No known key found for this signature in database
GPG Key ID: 559B3DEDDDF8FF82

@ -209,9 +209,13 @@ func compListReleases(toComplete string, cfg *action.Configuration) ([]string, c
}
var choices []string
uniqueNames := map[string]bool{}
for _, res := range results {
if ok := uniqueNames[res.Name]; !ok {
uniqueNames[res.Name] = true
choices = append(choices, res.Name)
}
}
return choices, cobra.ShellCompDirectiveNoFileComp
}

Loading…
Cancel
Save