Skip to content

Commit 47775a8

Browse files
cypharthaJeztah
authored andcommitted
docs: include required tools in source tree
In order to be able to build the documentation without internet access (as is required by some distribution build systems), all of the source code needed for the build needs to be available in the source tarball. This used to be possible with the docker-cli sources but was accidentally broken with some CI changes that switched to downloading the tools (by modifying go.mod as part of the docs build script). This pattern also maked documentation builds less reproducible since the tool version used was not based on the source code version. Fixes: 7dc35c0 ("validate manpages target") Fixes: a650f4d ("switch to cli-docs-tool for yaml docs generation") Signed-off-by: Aleksa Sarai <[email protected]> Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent b199ece commit 47775a8

Some content is hidden

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

50 files changed

+11144
-103
lines changed

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: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,18 @@ set -eu
44

55
: "${MD2MAN_VERSION=v2.0.6}"
66

7-
export GO111MODULE=auto
8-
9-
function clean {
10-
rm -rf "$buildir"
7+
function clean() {
8+
rm -f go.mod
119
}
1210

13-
buildir=$(mktemp -d -t docker-cli-docsgen.XXXXXXXXXX)
11+
export GO111MODULE=auto
1412
trap clean EXIT
1513

16-
(
17-
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
32-
)
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
3319

3420
mkdir -p man/man1
3521
(set -x ; /tmp/gen-manpages --root "." --target "$(pwd)/man/man1")

scripts/docs/generate-md.sh

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,16 @@ set -eu
44

55
: "${CLI_DOCS_TOOL_VERSION=v0.9.0}"
66

7-
export GO111MODULE=auto
8-
9-
function clean {
10-
rm -rf "$buildir"
7+
function clean() {
8+
rm -f go.mod
119
}
1210

13-
buildir=$(mktemp -d -t docker-cli-docsgen.XXXXXXXXXX)
11+
export GO111MODULE=auto
1412
trap clean EXIT
1513

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-
)
14+
./scripts/vendor init
15+
# build docsgen
16+
go build -mod=vendor -modfile=vendor.mod -tags docsgen -o /tmp/docsgen ./docs/generate/generate.go
3117

3218
(
3319
set -x

scripts/docs/generate-yaml.sh

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,16 @@ set -eu
44

55
: "${CLI_DOCS_TOOL_VERSION=v0.9.0}"
66

7-
export GO111MODULE=auto
8-
9-
function clean {
10-
rm -rf "$buildir"
7+
function clean() {
8+
rm -f go.mod
119
}
1210

13-
buildir=$(mktemp -d -t docker-cli-docsgen.XXXXXXXXXX)
11+
export GO111MODULE=auto
1412
trap clean EXIT
1513

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-
)
14+
./scripts/vendor init
15+
# build docsgen
16+
go build -mod=vendor -modfile=vendor.mod -tags docsgen -o /tmp/docsgen ./docs/generate/generate.go
3117

3218
mkdir -p docs/yaml
3319
set -x

vendor.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ go 1.23.0
99
require (
1010
dario.cat/mergo v1.0.1
1111
github.com/containerd/platforms v1.0.0-rc.1
12+
github.com/cpuguy83/go-md2man/v2 v2.0.6
1213
github.com/creack/pty v1.1.24
1314
github.com/distribution/reference v0.6.0
1415
github.com/docker/cli-docs-tool v0.9.0
@@ -88,6 +89,7 @@ require (
8889
github.com/prometheus/common v0.55.0 // indirect
8990
github.com/prometheus/procfs v0.15.1 // indirect
9091
github.com/rivo/uniseg v0.2.0 // indirect
92+
github.com/russross/blackfriday/v2 v2.1.0 // indirect
9193
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
9294
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
9395
go.etcd.io/etcd/raft/v3 v3.5.16 // indirect

vendor.sum

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3
3737
github.com/containerd/platforms v1.0.0-rc.1 h1:83KIq4yy1erSRgOVHNk1HYdPvzdJ5CnsWaRoJX4C41E=
3838
github.com/containerd/platforms v1.0.0-rc.1/go.mod h1:J71L7B+aiM5SdIEqmd9wp6THLVRzJGXfNuWCZCllLA4=
3939
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
40+
github.com/cpuguy83/go-md2man/v2 v2.0.6 h1:XJtiaUW6dEEqVuZiMTn1ldk455QWwEIsMIJlo5vtkx0=
41+
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
4042
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
4143
github.com/creack/pty v1.1.24 h1:bJrF4RRfyJnbTJqzRLHzcGaZK1NeM5kTC9jGgovnR1s=
4244
github.com/creack/pty v1.1.24/go.mod h1:08sCNb52WyoAwi2QDyzUCTgcvVFhUzewun7wtTfvcwE=
@@ -236,6 +238,7 @@ github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
236238
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
237239
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
238240
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
241+
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
239242
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
240243
github.com/sirupsen/logrus v1.0.6/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc=
241244
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=

vendor/github.com/cpuguy83/go-md2man/v2/.gitignore

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)