feat(comp): Add descriptions for kube-context comp

Ref: HIP 0008

When completing a kube-context, extra information will be shown for
shells that support completions (fish, zsh).  For example:

$ helm --kube-context <TAB>
acc       -- accept
default   -- k3d-k3s-default
lab       -- lab
lab2      -- cluster.local

Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
pull/9243/head
Marc Khouzam 4 years ago
parent b0d567accd
commit 7dee24daae

@ -131,13 +131,13 @@ func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string
if config, err := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(
loadingRules,
&clientcmd.ConfigOverrides{}).RawConfig(); err == nil {
ctxs := []string{}
for name := range config.Contexts {
comps := []string{}
for name, context := range config.Contexts {
if strings.HasPrefix(name, toComplete) {
ctxs = append(ctxs, name)
comps = append(comps, fmt.Sprintf("%s\t%s", name, context.Cluster))
}
}
return ctxs, cobra.ShellCompDirectiveNoFileComp
return comps, cobra.ShellCompDirectiveNoFileComp
}
return nil, cobra.ShellCompDirectiveNoFileComp
})

Loading…
Cancel
Save