From 3d80b7b0a74645feb7e3a044b74c04e806e35a3d Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 4 Jul 2024 21:07:31 +0200 Subject: [PATCH 1/2] 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. Signed-off-by: Sebastiaan van Stijn --- dockerfiles/Dockerfile.dev | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dockerfiles/Dockerfile.dev b/dockerfiles/Dockerfile.dev index 365c5e4216b4..f387763e4625 100644 --- a/dockerfiles/Dockerfile.dev +++ b/dockerfiles/Dockerfile.dev @@ -35,6 +35,7 @@ RUN --mount=type=cache,target=/root/.cache/go-build \ FROM golang AS dev RUN apk add --no-cache \ bash \ + bash-completion \ build-base \ ca-certificates \ coreutils \ @@ -44,7 +45,8 @@ RUN apk add --no-cache \ nano RUN echo -e "\nYou are now in a development container. Run '\e\033[1mmake help\e\033[0m' to learn about\navailable make targets.\n" > /etc/motd \ - && echo -e "cat /etc/motd\nPS1=\"\e[0;32m\u@docker-cli-dev\\$ \e[0m\"" >> /root/.bashrc + && echo -e "cat /etc/motd\nPS1=\"\e[0;32m\u@docker-cli-dev\\$ \e[0m\"" >> /root/.bashrc \ + && echo -e "source /etc/bash/bash_completion.sh" >> /root/.bashrc CMD bash ENV DISABLE_WARN_OUTSIDE_CONTAINER=1 ENV PATH=$PATH:/go/src/github.com/docker/cli/build From 3f3ecb94c55266d97749907b948b5db1391d2b25 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 4 Jul 2024 21:18:04 +0200 Subject: [PATCH 2/2] 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. Signed-off-by: Sebastiaan van Stijn --- Makefile | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Makefile b/Makefile index 8469c6031813..6b529faef0fb 100644 --- a/Makefile +++ b/Makefile @@ -86,6 +86,16 @@ mod-outdated: ## check outdated dependencies authors: ## generate AUTHORS file from git history scripts/docs/generate-authors.sh +.PHONY: completion +completion: binary +completion: /etc/bash_completion.d/docker +completion: ## generate and install the completion scripts + +.PHONY: /etc/bash_completion.d/docker +/etc/bash_completion.d/docker: ## generate and install the bash-completion script + mkdir -p /etc/bash_completion.d + docker completion bash > /etc/bash_completion.d/docker + .PHONY: manpages manpages: ## generate man pages from go source and markdown scripts/docs/generate-man.sh