Repository navigation
Auto-completion framework for plugins - #7468
Merged
Merged
Conversation
Member
Author
|
The tests pass on my machine. I'll have to investigate. |
Allow plugins to optionally specify their sub-cmds and flags through a simple yaml file. When generating the completion script with the command 'helm completion <bash|zsh>' (and only then), helm will look for that yaml file in the plugin's directory. If the file exists, helm will create cobra commands and flags so that the completion script will handle them. Signed-off-by: Marc Khouzam <[email protected]>
marckhouzam
force-pushed
the
feat/pluginCompletion
branch
3 times, most recently
from
January 31, 2020 03:33
5d4658f to
89ee0f8
Compare
For each plugin, helm registers a ValidArgsFunction which the completion script will call when it needs dynamic completion. This ValidArgsFunction will setup the plugin environment and then call the executable `plugin.complete`, if it is provided by the plugin. The output of the call to `plugin.complete` will be used as completion choices. The last line of the output can optionally be used by the plugin to specify a completion directive. Signed-off-by: Marc Khouzam <[email protected]>
marckhouzam
force-pushed
the
feat/pluginCompletion
branch
from
January 31, 2020 15:15
89ee0f8 to
82bfe37
Compare
Member
Author
|
The test failures were caused by shell script differences in the tests between my machine and the CI image. (This is one of the reasons why we now have helm completions coded in Go instead of shell. However, for plugins, which may not be go programs, shell scripts are a possibility, as I implemented in the tests). |
Member
Author
|
There are acceptance-tests written for this feature: helm/acceptance-testing#63 |
Member
I think that would be great, but we can start here and see how things shake out as users play with this new functionality. I like to err on the side of "less is more". :) |
Member
Author
|
Thanks @bacongobbler ! As the user-facing API is approved, I'll post a PR to helm-www to document 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.
Closes #7043
This PR adds a framework allowing plugins to provide both static auto-completion and dynamic auto-completion, as described in #7043
In summary, with this PR plugins could optionally provide:
completion.yamlfile to specify all flags and sub-commands to be completedplugin.completeexecutable to be called when dynamic completions are required (i.e., when the list of flags and sub-commands does not provide the required completion)I've prepared examples of how to use this framework in the
fullstatusplugin and the2to3plugin.The new
completion.yamlfile providing static completion can be seen athttps://github.com/marckhouzam/helm-fullstatus/blob/master/completion.yaml and https://github.com/marckhouzam/helm-2to3/blob/master/completion.yaml
For the
fullstatusplugin, the newplugin.completefile providing dynamic completion can be seen athttps://github.com/marckhouzam/helm-fullstatus/blob/master/plugin.complete
For the
2to3plugin, I've used the actual go binary to provide simple dynamic completion, as can be seen in the following commit: marckhouzam/helm-2to3@0e22f70To test:
This PR includes go tests for the new feature.
A first pass at some user documentation can be see in the description of #7043
Of note:
Questions for maintainers:
plugin.yamlfile be enhanced to allow plugin developers to specify which files should be used to provide completions? I've gone an easier route and hard-coded the files to be<pluginRootDir>/completion.yamland<pluginRootDir>/plugin.completefor every plugin.