File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -67,20 +67,20 @@ dynbinary: ## build dynamically linked binary
6767
6868.PHONY : plugins
6969plugins : # # build example CLI plugins
70- ./ scripts/build/plugins
70+ scripts/build/plugins
7171
7272.PHONY : vendor
7373vendor : # # update vendor with go modules
7474 rm -rf vendor
75- ./ scripts/vendor update
75+ scripts/with-go-mod.sh scripts/vendor update
7676
7777.PHONY : validate-vendor
7878validate-vendor : # # validate vendor
79- ./ scripts/vendor validate
79+ scripts/with-go-mod.sh scripts/vendor validate
8080
8181.PHONY : mod-outdated
8282mod-outdated : # # check outdated dependencies
83- ./ scripts/vendor outdated
83+ scripts/with-go-mod.sh scripts/vendor outdated
8484
8585.PHONY : authors
8686authors : # # generate AUTHORS file from git history
@@ -115,15 +115,15 @@ shell-completion: ## generate shell-completion scripts
115115
116116.PHONY : manpages
117117manpages : # # generate man pages from go source and markdown
118- scripts/docs/generate-man.sh
118+ scripts/with-go-mod.sh scripts/ docs/generate-man.sh
119119
120120.PHONY : mddocs
121121mddocs : # # generate markdown files from go source
122- scripts/docs/generate-md.sh
122+ scripts/with-go-mod.sh scripts/ docs/generate-md.sh
123123
124124.PHONY : yamldocs
125125yamldocs : # # generate documentation YAML files consumed by docs repo
126- scripts/docs/generate-yaml.sh
126+ scripts/with-go-mod.sh scripts/ docs/generate-yaml.sh
127127
128128.PHONY : help
129129help : # # print this help
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ RUN --mount=target=/context \
1616 --mount=target=/go/pkg/mod,type=cache <<EOT
1717set -e
1818rsync -a /context/. .
19- ./scripts/vendor update
19+ ./scripts/with-go-mod.sh ./scripts/ vendor update
2020mkdir /out
2121cp -r vendor.mod vendor.sum vendor /out
2222EOT
@@ -32,12 +32,12 @@ rsync -a /context/. .
3232git add -A
3333rm -rf vendor
3434cp -rf /out/* .
35- ./scripts/vendor validate
35+ ./scripts/with-go-mod.sh ./scripts/ vendor validate
3636EOT
3737
3838FROM psampaz/go-mod-outdated:${MODOUTDATED_VERSION} AS go-mod-outdated
3939FROM base AS outdated
4040RUN --mount=target=.,rw \
4141 --mount=target=/go/pkg/mod,type=cache \
4242 --mount=from=go-mod-outdated,source=/home/go-mod-outdated,target=/usr/bin/go-mod-outdated \
43- ./scripts/vendor outdated
43+ ./scripts/with-go-mod.sh ./scripts/ vendor outdated
Original file line number Diff line number Diff line change 22
33set -eu
44
5- : " ${MD2MAN_VERSION=v2.0.6 } "
5+ : " ${GO_MD2MAN := go-md2man } "
66
7- function clean() {
8- rm -f go.mod
9- }
10-
11- export GO111MODULE=auto
12- trap clean EXIT
13-
14- ./scripts/vendor init
15- # build gen-manpages
16- go build -mod=vendor -modfile=vendor.mod -tags manpages -o /tmp/gen-manpages ./man/generate.go
17- # build go-md2man
18- go build -mod=vendor -modfile=vendor.mod -o /tmp/go-md2man ./vendor/github.com/cpuguy83/go-md2man/v2
7+ if ! command -v " $GO_MD2MAN " > /dev/null; then
8+ (
9+ set -x
10+ go build -mod=vendor -modfile=vendor.mod -o ./build/tools/go-md2man ./vendor/github.com/cpuguy83/go-md2man/v2
11+ )
12+ GO_MD2MAN=$( realpath ./build/tools/go-md2man)
13+ fi
1914
2015mkdir -p man/man1
21- (set -x ; /tmp/gen-manpages --root " ." --target " $( pwd) /man/man1" )
16+ (
17+ set -x
18+ go run -mod=vendor -modfile=vendor.mod -tags manpages ./man/generate.go --root " ." --target " ./man/man1"
19+ )
2220
2321(
2422 cd man
@@ -31,6 +29,9 @@ mkdir -p man/man1
3129 continue
3230 fi
3331 mkdir -p " ./man${num} "
34- (set -x ; /tmp/go-md2man -in " $FILE " -out " ./man${num} /${name} " )
32+ (
33+ set -x ;
34+ " $GO_MD2MAN " -in " $FILE " -out " ./man${num} /${name} "
35+ )
3536 done
3637)
Original file line number Diff line number Diff line change 22
33set -eu
44
5- : " ${CLI_DOCS_TOOL_VERSION=v0.9.0} "
6-
7- function clean() {
8- rm -f go.mod
9- }
10-
11- export GO111MODULE=auto
12- trap clean EXIT
13-
14- ./scripts/vendor init
15- # build docsgen
16- go build -mod=vendor -modfile=vendor.mod -tags docsgen -o /tmp/docsgen ./docs/generate/generate.go
17-
185(
196 set -x
20- /tmp/docsgen --formats md --source " $( pwd ) /docs/reference/commandline" --target " $( pwd ) /docs/reference/commandline"
7+ go run -mod=vendor -modfile=vendor.mod -tags docsgen ./docs/generate/generate.go --formats md --source " . /docs/reference/commandline" --target " . /docs/reference/commandline"
218)
229
2310# remove generated help.md file
Original file line number Diff line number Diff line change 22
33set -eu
44
5- : " ${CLI_DOCS_TOOL_VERSION=v0.9.0} "
6-
7- function clean() {
8- rm -f go.mod
9- }
10-
11- export GO111MODULE=auto
12- trap clean EXIT
13-
14- ./scripts/vendor init
15- # build docsgen
16- go build -mod=vendor -modfile=vendor.mod -tags docsgen -o /tmp/docsgen ./docs/generate/generate.go
17-
185mkdir -p docs/yaml
196set -x
20- /tmp/docsgen --formats yaml --source " $( pwd ) /docs/reference/commandline" --target " $( pwd ) /docs/yaml"
7+ go run -mod=vendor -modfile=vendor.mod -tags docsgen ./docs/generate/generate.go --formats yaml --source " . /docs/reference/commandline" --target " . /docs/yaml"
Original file line number Diff line number Diff line change @@ -13,15 +13,6 @@ if [ -z "$TYP" ]; then
1313 usage
1414fi
1515
16- init () {
17- # create dummy go.mod, see comment in vendor.mod
18- cat > go.mod << EOL
19- module github.com/docker/cli
20-
21- go 1.23.0
22- EOL
23- }
24-
2516update () {
2617 (set -x ; go mod tidy -modfile=vendor.mod; go mod vendor -modfile=vendor.mod)
2718}
@@ -44,20 +35,14 @@ outdated() {
4435}
4536
4637case $TYP in
47- " init" )
48- init
49- ;;
5038 " update" )
51- init
5239 update
5340 ;;
5441 " validate" )
55- init
5642 update
5743 validate
5844 ;;
5945 " outdated" )
60- init
6146 outdated
6247 ;;
6348 * )
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ #
3+ # This script is used to coerce certain commands which rely on the presence of
4+ # a go.mod into working with our repository. It works by creating a fake
5+ # go.mod, running a specified command (passed via arguments), and removing it
6+ # when the command is finished. This script should be dropped when this
7+ # repository is a proper Go module with a permanent go.mod.
8+
9+ set -e
10+
11+ SCRIPTDIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
12+ ROOTDIR=" $( cd " ${SCRIPTDIR} /.." && pwd) "
13+
14+ if test -e " ${ROOTDIR} /go.mod" ; then
15+ {
16+ scriptname=$( basename " $0 " )
17+ cat >&2 << - EOF
18+ $scriptname : WARN: go.mod exists in the repository root!
19+ $scriptname : WARN: Using your go.mod instead of our generated version -- this may misbehave!
20+ EOF
21+ } >&2
22+ else
23+ set -x
24+
25+ tee " ${ROOTDIR} /go.mod" >&2 << - EOF
26+ module github.com/docker/cli
27+
28+ go 1.23.0
29+ EOF
30+ trap ' rm -f "${ROOTDIR}/go.mod"' EXIT
31+ fi
32+
33+ GO111MODULE=on GOTOOLCHAIN=local " $@ "
You can’t perform that action at this time.
0 commit comments