Skip to content
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

install bash-completion in dev container #5232

Merged
merged 2 commits into from
Jul 8, 2024

Conversation

thaJeztah
Copy link
Member

Dockerfile.dev: install bash-completion in dev container

It's not initialized, because there's no docker command installed
by default, but at least this makes sure that the basics are present
for testing.

Makefile: add completion target

Add a "completion" target to install the generated completion
scripts inside the dev-container. As generating this script
depends on the docker binary, it calls "make binary" first.

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

@codecov-commenter
Copy link

codecov-commenter commented Jul 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 61.49%. Comparing base (9bb1a62) to head (3f3ecb9).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5232   +/-   ##
=======================================
  Coverage   61.48%   61.49%           
=======================================
  Files         298      298           
  Lines       20811    20811           
=======================================
+ Hits        12795    12797    +2     
+ Misses       7103     7102    -1     
+ Partials      913      912    -1     

Makefile Outdated
Comment on lines 89 to 97
.PHONY: completion
completion: binary ## install the generated bash-completion script in the dev container
docker completion bash > /etc/bash_completion.d/docker
Copy link
Member

Choose a reason for hiding this comment

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

does this need to be a separate make command?
Wondering if we could include the completion scripts (for all shells) inside the dev container by default.

Copy link
Member Author

Choose a reason for hiding this comment

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

I was considering that, but we currently only have Bash installed. I think
we can consider adding more shells (but need to look at how much extra
time (and space) that would take by default to start the dev-container).

But yes, we can already split targets to prepare for that; I pushed an
update that splits the bash part to a separate make target 👍 PTAL

It's not initialized, because there's no `docker` command installed
by default, but at least this makes sure that the basics are present
for testing.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
Makefile Outdated
completion: /etc/bash_completion.d/docker
completion: ## generate and install the completion scripts

/etc/bash_completion.d/docker: FORCE ## generate and install the bash-completion script
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we can just use .PHONY here:

Suggested change
/etc/bash_completion.d/docker: FORCE ## generate and install the bash-completion script
.PHONY: /etc/bash_completion.d/docker
/etc/bash_completion.d/docker:

Copy link
Member

Choose a reason for hiding this comment

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

Docs seem to support using PHONY

Using ‘.PHONY’ is more explicit and more efficient. However, other versions of make do not support ‘.PHONY’; thus ‘FORCE’ appears in many makefiles.

https://www.gnu.org/software/make/manual/html_node/Force-Targets.html

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, yeah, both should work here; I picked FORCE to make it explicit it's not a "fake" target, so an actual file, but would still have to be forced; I had some recollection hat was the preferred way somewhere, but can't find that back (maybe it was some discussion in another project).

Copy link
Member Author

Choose a reason for hiding this comment

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

updated 👍

completion: ## generate and install the completion scripts

/etc/bash_completion.d/docker: FORCE ## generate and install the bash-completion script
docker completion bash > /etc/bash_completion.d/docker
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should also make sure that the directory exists:

Suggested change
docker completion bash > /etc/bash_completion.d/docker
mkdir -p /etc/bash_completion.d
docker completion bash > /etc/bash_completion.d/docker

Copy link
Member Author

Choose a reason for hiding this comment

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

Good one; I wrote it with the dev-container in mind (which had it set up already), but doesn't hurt to add

Copy link
Member Author

Choose a reason for hiding this comment

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

updated 👍

Add a "completion" target to install the generated completion
scripts inside the dev-container. As generating this script
depends on the docker binary, it calls "make binary" first.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
@thaJeztah
Copy link
Member Author

thx! I'll bring this one in, and rebase #5238

@thaJeztah thaJeztah merged commit cfbf88f into docker:master Jul 8, 2024
88 checks passed
@thaJeztah thaJeztah deleted the dev_completion branch July 8, 2024 17:21
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