Skip to content

helm v3: dynamic completion of releases - #5829

Merged
bacongobbler merged 2 commits into
helm:dev-v3from
VilledeMontreal:feat-v3/dynamicCopmpletionReleases
Jun 5, 2019
Merged

bacongobbler merged 2 commits into
helm:dev-v3from
VilledeMontreal:feat-v3/dynamicCopmpletionReleases

Conversation

@marckhouzam

Copy link
Copy Markdown
Member

Add dynamic completion after

helm status <TAB>
helm uninstall <TAB>
helm history <TAB>
helm test run <TAB>
helm upgrade <TAB>
helm get <subcommand> <TAB>
helm rollback <TAB>

by fetching the list of releases from the cluster.

Special notes for your reviewer:

This PR is the adapted v3 version of #5562 as requested by @technosophos.
It puts in the foundation for dynamic completion support in Helm v3.
It is inspired by the dynamic completion provided by kubectl.
Both bash and zsh are handled.

As dynamic completion actually sends queries to the cluster, this PR handles the use of Helm flags that affect which cluster should be contacted:

--kubeconfig 
--kube-context 
--home 
--namespace
-n

This PR requires the use of Cobra v0.0.4 which allows dynamic completion to co-exist between helm and kubectl (while Cobra v0.0.3 had a bug that would cause the two to clash).

The version of Cobra used in dev-v3 is older than the one used
for the master branch (helm v2). Although the dev-v3 branch
was based on master and therefore had the same Cobra version
originally, it was changed a couple of times to choose Cobra
tagged versions instead.

However, the currently used 0.0.3 version of Cobra is older than
the version of Cobra used on the master branch. Therefore, some of the
improvements made to Cobra and used by helm v2 are not available
to helm v3 currently.

This commit brings Cobra to its latest available version of 0.0.4.

Bringing Cobra up-to-date is essential for upcoming work being
prepared for dynamic bash-completion; there are bug fixes in
Cobra that are necessary for dynamic bash-completion to work
properly. Specifically,
    spf13/cobra#730
 which fixes
    spf13/cobra#694
is essential to avoid the risk of colliding and possibly
breaking kubectl dynamic bash-completion once helm v3 has its
own dynamic completion.

Signed-off-by: Marc Khouzam <[email protected]>
This commit adds dynamic completion for the commands
   helm status <TAB>
   helm uninstall <TAB>
   helm history <TAB>
   helm test run <TAB>
   helm upgrade <TAB>
   helm get <subcommand> <TAB>
   helm rollback <TAB>

Aliases of commands are automatically taken care of, such as
  helm delete <TAB>
which is an alias of
  helm uninstall

Support for override flags in completion is included for
such dynamic completion.

The list of release names to complete is obtained by running
  helm list $(__helm_override_flags) -a -q -m 1000 -f ${filter}
where
  ${__helm_override_flags} is any user-specified flags part of
      --kubeconfig --kube-context --home --namespace -n
  ${filter} is whatever prefix the user may have already typed
      for the release name

Signed-off-by: Marc Khouzam <[email protected]>
@helm-bot helm-bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jun 3, 2019
@marckhouzam marckhouzam changed the title Feat v3/dynamic copmpletion releases helm v3: dynamic completion of releases Jun 3, 2019
@bacongobbler bacongobbler added the v3.x Issues and Pull Requests related to the major version v3 label Jun 4, 2019

@bacongobbler bacongobbler left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for working on this!

@bacongobbler
bacongobbler merged commit 0b41b90 into helm:dev-v3 Jun 5, 2019
@marckhouzam
marckhouzam deleted the feat-v3/dynamicCopmpletionReleases branch June 5, 2019 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Denotes a PR that changes 30-99 lines, ignoring generated files. v3.x Issues and Pull Requests related to the major version v3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants