Skip to content

Commit 61cd986

Browse files
authored
Merge pull request #4903 from thaJeztah/carry_docs_no_internet
docs: include required tools in source tree
2 parents 30cac75 + 535bb6c commit 61cd986

54 files changed

Lines changed: 11183 additions & 149 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Makefile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,20 @@ dynbinary: ## build dynamically linked binary
6767

6868
.PHONY: plugins
6969
plugins: ## build example CLI plugins
70-
./scripts/build/plugins
70+
scripts/build/plugins
7171

7272
.PHONY: vendor
7373
vendor: ## 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
7878
validate-vendor: ## validate vendor
79-
./scripts/vendor validate
79+
scripts/with-go-mod.sh scripts/vendor validate
8080

8181
.PHONY: mod-outdated
8282
mod-outdated: ## check outdated dependencies
83-
./scripts/vendor outdated
83+
scripts/with-go-mod.sh scripts/vendor outdated
8484

8585
.PHONY: authors
8686
authors: ## generate AUTHORS file from git history
@@ -115,15 +115,15 @@ shell-completion: ## generate shell-completion scripts
115115

116116
.PHONY: manpages
117117
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
119119

120120
.PHONY: mddocs
121121
mddocs: ## 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
125125
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
127127

128128
.PHONY: help
129129
help: ## print this help

dockerfiles/Dockerfile.vendor

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ RUN --mount=target=/context \
1616
--mount=target=/go/pkg/mod,type=cache <<EOT
1717
set -e
1818
rsync -a /context/. .
19-
./scripts/vendor update
19+
./scripts/with-go-mod.sh ./scripts/vendor update
2020
mkdir /out
2121
cp -r vendor.mod vendor.sum vendor /out
2222
EOT
@@ -32,12 +32,12 @@ rsync -a /context/. .
3232
git add -A
3333
rm -rf vendor
3434
cp -rf /out/* .
35-
./scripts/vendor validate
35+
./scripts/with-go-mod.sh ./scripts/vendor validate
3636
EOT
3737

3838
FROM psampaz/go-mod-outdated:${MODOUTDATED_VERSION} AS go-mod-outdated
3939
FROM base AS outdated
4040
RUN --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

docs/generate/go.mod

Lines changed: 0 additions & 13 deletions
This file was deleted.

docs/generate/tools.go

Lines changed: 0 additions & 7 deletions
This file was deleted.

man/go.mod

Lines changed: 0 additions & 15 deletions
This file was deleted.

man/tools.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,4 @@
22

33
package main
44

5-
import (
6-
_ "github.com/cpuguy83/go-md2man/v2"
7-
_ "github.com/spf13/cobra"
8-
_ "github.com/spf13/cobra/doc"
9-
_ "github.com/spf13/pflag"
10-
)
5+
import _ "github.com/cpuguy83/go-md2man/v2"

scripts/docs/generate-man.sh

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,22 @@
22

33
set -eu
44

5-
: "${MD2MAN_VERSION=v2.0.6}"
5+
: "${GO_MD2MAN:=go-md2man}"
66

7-
export GO111MODULE=auto
8-
9-
function clean {
10-
rm -rf "$buildir"
11-
}
12-
13-
buildir=$(mktemp -d -t docker-cli-docsgen.XXXXXXXXXX)
14-
trap clean EXIT
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
1514

15+
mkdir -p man/man1
1616
(
1717
set -x
18-
cp -r . "$buildir/"
19-
cd "$buildir"
20-
# init dummy go.mod
21-
./scripts/vendor init
22-
# install go-md2man and copy man/tools.go in root folder
23-
# to be able to fetch the required dependencies
24-
go mod edit -modfile=vendor.mod -require=github.com/cpuguy83/go-md2man/v2@${MD2MAN_VERSION}
25-
cp man/tools.go .
26-
# update vendor
27-
./scripts/vendor update
28-
# build gen-manpages
29-
go build -mod=vendor -modfile=vendor.mod -tags manpages -o /tmp/gen-manpages ./man/generate.go
30-
# build go-md2man
31-
go build -mod=vendor -modfile=vendor.mod -o /tmp/go-md2man ./vendor/github.com/cpuguy83/go-md2man/v2
18+
go run -mod=vendor -modfile=vendor.mod -tags manpages ./man/generate.go --root "." --target "./man/man1"
3219
)
3320

34-
mkdir -p man/man1
35-
(set -x ; /tmp/gen-manpages --root "." --target "$(pwd)/man/man1")
36-
3721
(
3822
cd man
3923
for FILE in *.md; do
@@ -45,6 +29,9 @@ mkdir -p man/man1
4529
continue
4630
fi
4731
mkdir -p "./man${num}"
48-
(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+
)
4936
done
5037
)

scripts/docs/generate-md.sh

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,9 @@
22

33
set -eu
44

5-
: "${CLI_DOCS_TOOL_VERSION=v0.9.0}"
6-
7-
export GO111MODULE=auto
8-
9-
function clean {
10-
rm -rf "$buildir"
11-
}
12-
13-
buildir=$(mktemp -d -t docker-cli-docsgen.XXXXXXXXXX)
14-
trap clean EXIT
15-
16-
(
17-
set -x
18-
cp -r . "$buildir/"
19-
cd "$buildir"
20-
# init dummy go.mod
21-
./scripts/vendor init
22-
# install cli-docs-tool and copy docs/tools.go in root folder
23-
# to be able to fetch the required dependencies
24-
go mod edit -modfile=vendor.mod -require=github.com/docker/cli-docs-tool@${CLI_DOCS_TOOL_VERSION}
25-
cp docs/generate/tools.go .
26-
# update vendor
27-
./scripts/vendor update
28-
# build docsgen
29-
go build -mod=vendor -modfile=vendor.mod -tags docsgen -o /tmp/docsgen ./docs/generate/generate.go
30-
)
31-
325
(
336
set -x
34-
/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"
358
)
369

3710
# remove generated help.md file

scripts/docs/generate-yaml.sh

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,6 @@
22

33
set -eu
44

5-
: "${CLI_DOCS_TOOL_VERSION=v0.9.0}"
6-
7-
export GO111MODULE=auto
8-
9-
function clean {
10-
rm -rf "$buildir"
11-
}
12-
13-
buildir=$(mktemp -d -t docker-cli-docsgen.XXXXXXXXXX)
14-
trap clean EXIT
15-
16-
(
17-
set -x
18-
cp -r . "$buildir/"
19-
cd "$buildir"
20-
# init dummy go.mod
21-
./scripts/vendor init
22-
# install cli-docs-tool and copy docs/tools.go in root folder
23-
# to be able to fetch the required dependencies
24-
go mod edit -modfile=vendor.mod -require=github.com/docker/cli-docs-tool@${CLI_DOCS_TOOL_VERSION}
25-
cp docs/generate/tools.go .
26-
# update vendor
27-
./scripts/vendor update
28-
# build docsgen
29-
go build -mod=vendor -modfile=vendor.mod -tags docsgen -o /tmp/docsgen ./docs/generate/generate.go
30-
)
31-
325
mkdir -p docs/yaml
336
set -x
34-
/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"

scripts/vendor

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,6 @@ if [ -z "$TYP" ]; then
1313
usage
1414
fi
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-
2516
update() {
2617
(set -x ; go mod tidy -modfile=vendor.mod; go mod vendor -modfile=vendor.mod)
2718
}
@@ -44,20 +35,14 @@ outdated() {
4435
}
4536

4637
case $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
*)

0 commit comments

Comments
 (0)