Skip to content

Conversation

@crazy-max
Copy link
Member

@crazy-max crazy-max commented Mar 12, 2023

- What I did

I was working on targets completion for the buildx bake command in docker/buildx#1674 and found out we don't have any bash completion for docker-buildx plugin.

- How I did it

- How to verify it

$ mkdir -p ~/.local/share/bash-completion/completions
$ cp ./contrib/completion/bash/docker ~/.local/share/bash-completion/completions/docker
$ _completion_loader docker

$ docker build [tab][tab]
build    builder  buildx

$ docker buildx [tab][tab]
bake        create      help        inspect     prune       stop        version     
build       du          imagetools  ls          rm          use

$ docker buildx b [tab][tab]
bake   build

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

Signed-off-by: CrazyMax <github@crazymax.dev>
@crazy-max crazy-max requested a review from albers as a code owner March 12, 2023 01:06
@codecov-commenter
Copy link

Codecov Report

Merging #4089 (1d4f9fa) into master (cb5463a) will decrease coverage by 0.01%.
The diff coverage is n/a.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4089      +/-   ##
==========================================
- Coverage   59.15%   59.14%   -0.01%     
==========================================
  Files         285      287       +2     
  Lines       24725    24741      +16     
==========================================
+ Hits        14627    14634       +7     
- Misses       9212     9221       +9     
  Partials      886      886              

@thaJeztah
Copy link
Member

Guess it won't hurt to have it in this script, although we now also have the Cobra-generated completion in the CLI on master (and 23.0+) since #3429

@crazy-max
Copy link
Member Author

crazy-max commented Mar 12, 2023

Guess it won't hurt to have it in this script, although we now also have the Cobra-generated completion in the CLI on master (and 23.0+) since #3429

Yeah but it doesn't work for plugins afaik:

$ docker build [tab][tab]
build    builder

Compose works because there is the bash completion available I guess.

_docker_container_wait
}

BUILDX_PLUGIN_PATH=$(docker info --format '{{range .ClientInfo.Plugins}}{{if eq .Name "buildx"}}{{.Path}}{{end}}{{end}}')
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe for a follow-up, but I think we should try to make it generic for plugins. We should call docker info only once and process the result, depending the plugin name.
It might be tricky though, so maybe for a follow-up 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for your feedback. I will make it more generic to support all plugins. Keep you posted.

@crazy-max crazy-max marked this pull request as draft March 13, 2023 15:43
@crazy-max crazy-max deleted the buildx-completion branch March 21, 2023 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants