File tree 7 files changed +61
-68
lines changed
7 files changed +61
-68
lines changed Original file line number Diff line number Diff line change @@ -67,20 +67,20 @@ dynbinary: ## build dynamically linked binary
67
67
68
68
.PHONY : plugins
69
69
plugins : # # build example CLI plugins
70
- ./ scripts/build/plugins
70
+ scripts/build/plugins
71
71
72
72
.PHONY : vendor
73
73
vendor : # # update vendor with go modules
74
74
rm -rf vendor
75
- ./ scripts/vendor update
75
+ scripts/with-go-mod.sh scripts/vendor update
76
76
77
77
.PHONY : validate-vendor
78
78
validate-vendor : # # validate vendor
79
- ./ scripts/vendor validate
79
+ scripts/with-go-mod.sh scripts/vendor validate
80
80
81
81
.PHONY : mod-outdated
82
82
mod-outdated : # # check outdated dependencies
83
- ./ scripts/vendor outdated
83
+ scripts/with-go-mod.sh scripts/vendor outdated
84
84
85
85
.PHONY : authors
86
86
authors : # # generate AUTHORS file from git history
@@ -115,15 +115,15 @@ shell-completion: ## generate shell-completion scripts
115
115
116
116
.PHONY : manpages
117
117
manpages : # # 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
119
119
120
120
.PHONY : mddocs
121
121
mddocs : # # generate markdown files from go source
122
- scripts/docs/generate-md.sh
122
+ scripts/with-go-mod.sh scripts/ docs/generate-md.sh
123
123
124
124
.PHONY : yamldocs
125
125
yamldocs : # # 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
127
127
128
128
.PHONY : help
129
129
help : # # print this help
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ RUN --mount=target=/context \
16
16
--mount=target=/go/pkg/mod,type=cache <<EOT
17
17
set -e
18
18
rsync -a /context/. .
19
- ./scripts/vendor update
19
+ ./scripts/with-go-mod.sh ./scripts/ vendor update
20
20
mkdir /out
21
21
cp -r vendor.mod vendor.sum vendor /out
22
22
EOT
@@ -32,12 +32,12 @@ rsync -a /context/. .
32
32
git add -A
33
33
rm -rf vendor
34
34
cp -rf /out/* .
35
- ./scripts/vendor validate
35
+ ./scripts/with-go-mod.sh ./scripts/ vendor validate
36
36
EOT
37
37
38
38
FROM psampaz/go-mod-outdated:${MODOUTDATED_VERSION} AS go-mod-outdated
39
39
FROM base AS outdated
40
40
RUN --mount=target=.,rw \
41
41
--mount=target=/go/pkg/mod,type=cache \
42
42
--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 2
2
3
3
set -eu
4
4
5
- : " ${MD2MAN_VERSION=v2.0.6 } "
5
+ : " ${GO_MD2MAN := go-md2man } "
6
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 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
19
14
20
15
mkdir -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
+ )
22
20
23
21
(
24
22
cd man
@@ -31,6 +29,9 @@ mkdir -p man/man1
31
29
continue
32
30
fi
33
31
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
+ )
35
36
done
36
37
)
Original file line number Diff line number Diff line change 2
2
3
3
set -eu
4
4
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
-
18
5
(
19
6
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"
21
8
)
22
9
23
10
# remove generated help.md file
Original file line number Diff line number Diff line change 2
2
3
3
set -eu
4
4
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
-
18
5
mkdir -p docs/yaml
19
6
set -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
13
13
usage
14
14
fi
15
15
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
-
25
16
update () {
26
17
(set -x ; go mod tidy -modfile=vendor.mod; go mod vendor -modfile=vendor.mod)
27
18
}
@@ -44,20 +35,14 @@ outdated() {
44
35
}
45
36
46
37
case $TYP in
47
- " init" )
48
- init
49
- ;;
50
38
" update" )
51
- init
52
39
update
53
40
;;
54
41
" validate" )
55
- init
56
42
update
57
43
validate
58
44
;;
59
45
" outdated" )
60
- init
61
46
outdated
62
47
;;
63
48
* )
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