Repository navigation
helm v3: dynamic completion of releases - #5829
Merged
bacongobbler merged 2 commits intoJun 5, 2019
Merged
bacongobbler merged 2 commits into
bacongobbler merged 2 commits into
Conversation
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]>
bacongobbler
approved these changes
Jun 5, 2019
bacongobbler
left a comment
Member
There was a problem hiding this comment.
LGTM. Thanks for working on this!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add dynamic completion after
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:
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).