-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shell completion for loading docker images #2081
Comments
This sounds interesting, how do you propose to implement it? I think we will have some interesting portability concerns xref: #2038 depending on how it is implemented |
What I had in mind was using I suppose if the scope is limited to Docker and Podman, we should be able to achieve this from executing the binary since Podman CLI aims to be backwards-compatible with Docker to a point of |
in the #2038 case we aim to support having both installed, because you may e.g. need to build kubernetes images with
I don't think they're making this claim as strongly anymore. Within kind we've found that this is ... not the case once you're doing interesting things. We have explicit codepaths for both and they're not identical. |
I see, if the case is to support both, then I think this is something we can iterate on -- add support for one, then the other and append the results? I have yet to try loading image from podman so maybe I'm rambling nonsense, but if I submit a PR for supporting autocompletion on docker images now while we explore the podman route, would that be acceptable? Or would you prefer to wait until we find a common ground / universal approach for both? |
I guess it should be done on SHELL side, so create appropriate |
well we also have completion for other shells atm.
that seems reasonable, also it will probably be a different command. |
kubernetes/kubernetes#96087 might give an idea for this. |
cobra just overhauled completion significantly and we will need to update our existing support to handle this, I think kubernetes will also have some issues upgrading but will probably just disable the support from cobra. |
If I may chime in, Cobra's completion changes should be fully backwards-compatible, and I believe an upgrade should be transparent. If you have your own completions written in bash, you would need to write them in Go for them to work with different shells, but I don't believe you do. Are there specific issues you are referring to @BenTheElder ? |
IIRC there was some custom work for ZSH but I have not had time to look at this. It would be great if someone wanted to 😅 |
I've checked how completion was done for kind and you are all good. Specifically, kind uses Cobra's native zsh completion and does not use the bash-to-zsh conversion that kubectl was using up until kubernetes/kubernetes#96087, as can be seen here: kind/pkg/cmd/kind/completion/zsh/zsh.go Line 34 in c7f1d20
So, I am confident you can upgrade to Cobra 1.2.1 completely transparently. Also, using Beyond adding custom completions, there are two other improvements you may be interested in making: |
I think this is going to get really complex and potentially nightmareish if/when we switch to #2038 |
What would you like to be added:
Would be nice if I can get shell auto-completion from
kind load docker-image [TAB][TAB]
with the list of available images on my machine. Roughly the options can be retrieved by:or without the
<none>
images being included:Why is this needed:
As part of my development iteration, I need to repetitively load docker images. This would make my development iteration easier 😄
Other notes:
Happy to contribute this if maintainers would not mind reviewing the code!
The text was updated successfully, but these errors were encountered: