Skip to content

Commit

Permalink
switch to go module
Browse files Browse the repository at this point in the history
Looks like we are ready to switch to go module for this repo
as we are now compatible with Go's conventions (we are SemVer
since v23.0.0).

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
  • Loading branch information
crazy-max committed Mar 24, 2023
1 parent f5d698a commit 00955f5
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 46 deletions.
4 changes: 0 additions & 4 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,3 @@
/docs/vendor/
/docs/go.sum
profile.out

# top-level go.mod is not meant to be checked in
/go.mod
/go.sum
2 changes: 0 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
Dockerfile* linguist-language=Dockerfile
vendor.mod linguist-language=Go-Module
vendor.sum linguist-language=Go-Checksums
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,3 @@ Thumbs.db
/cli/winresources/versioninfo.json
/cli/winresources/*.syso
profile.out

# top-level go.mod is not meant to be checked in
/go.mod
/go.sum
2 changes: 1 addition & 1 deletion dockerfiles/Dockerfile.vendor
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ set -e
rsync -a /context/. .
./scripts/vendor update
mkdir /out
cp -r vendor.mod vendor.sum vendor /out
cp -r go.mod go.sum vendor /out
EOT

FROM scratch AS update
Expand Down
4 changes: 0 additions & 4 deletions vendor.mod → go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
module github.com/docker/cli

// 'vendor.mod' enables use of 'go mod vendor' to managed 'vendor/' directory.
// There is no 'go.mod' file, as that would imply opting in for all the rules
// around SemVer, which this repo cannot abide by as it uses CalVer.

go 1.18

require (
Expand Down
File renamed without changes.
8 changes: 3 additions & 5 deletions scripts/docs/generate-man.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,16 @@ trap clean EXIT
set -x
cp -r . "$buildir/"
cd "$buildir"
# init dummy go.mod
./scripts/vendor init
# install go-md2man and copy man/tools.go in root folder
# to be able to fetch the required dependencies
go mod edit -modfile=vendor.mod -require=github.com/cpuguy83/go-md2man/v2@${MD2MAN_VERSION}
go mod edit -require=github.com/cpuguy83/go-md2man/v2@${MD2MAN_VERSION}
cp man/tools.go .
# update vendor
./scripts/vendor update
# build gen-manpages
go build -mod=vendor -modfile=vendor.mod -tags manpages -o /tmp/gen-manpages ./man/generate.go
go build -mod=vendor -tags manpages -o /tmp/gen-manpages ./man/generate.go
# build go-md2man
go build -mod=vendor -modfile=vendor.mod -o /tmp/go-md2man ./vendor/github.com/cpuguy83/go-md2man/v2
go build -mod=vendor -o /tmp/go-md2man ./vendor/github.com/cpuguy83/go-md2man/v2
)

mkdir -p man/man1
Expand Down
6 changes: 2 additions & 4 deletions scripts/docs/generate-md.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,14 @@ trap clean EXIT
set -x
cp -r . "$buildir/"
cd "$buildir"
# init dummy go.mod
./scripts/vendor init
# install cli-docs-tool and copy docs/tools.go in root folder
# to be able to fetch the required depedencies
go mod edit -modfile=vendor.mod -require=github.com/docker/cli-docs-tool@${CLI_DOCS_TOOL_VERSION}
go mod edit -require=github.com/docker/cli-docs-tool@${CLI_DOCS_TOOL_VERSION}
cp docs/tools.go .
# update vendor
./scripts/vendor update
# build docsgen
go build -mod=vendor -modfile=vendor.mod -tags docsgen -o /tmp/docsgen ./docs/generate.go
go build -mod=vendor -tags docsgen -o /tmp/docsgen ./docs/generate.go
)

# yaml generation on docs repo needs the cli.md file: https://github.com/docker/cli/pull/3924#discussion_r1059986605
Expand Down
6 changes: 2 additions & 4 deletions scripts/docs/generate-yaml.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,14 @@ trap clean EXIT
set -x
cp -r . "$buildir/"
cd "$buildir"
# init dummy go.mod
./scripts/vendor init
# install cli-docs-tool and copy docs/tools.go in root folder
# to be able to fetch the required depedencies
go mod edit -modfile=vendor.mod -require=github.com/docker/cli-docs-tool@${CLI_DOCS_TOOL_VERSION}
go mod edit -require=github.com/docker/cli-docs-tool@${CLI_DOCS_TOOL_VERSION}
cp docs/generate/tools.go .
# update vendor
./scripts/vendor update
# build docsgen
go build -mod=vendor -modfile=vendor.mod -tags docsgen -o /tmp/docsgen ./docs/generate/generate.go
go build -mod=vendor -tags docsgen -o /tmp/docsgen ./docs/generate/generate.go
)

mkdir -p docs/yaml
Expand Down
28 changes: 10 additions & 18 deletions scripts/vendor
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,16 @@ if [ -z "$TYP" ]; then
usage
fi

init() {
# create dummy go.mod, see comment in vendor.mod
cat > go.mod <<EOL
module github.com/docker/cli
go 1.18
EOL
}

update() {
(set -x ; go mod tidy -compat=1.18 -modfile=vendor.mod; go mod vendor -modfile=vendor.mod)
(
set -x
go mod tidy -compat=1.18
go mod vendor
)
}

validate() {
diff=$(git status --porcelain -- vendor.mod vendor.sum vendor)
diff=$(git status --porcelain -- go.mod go.sum vendor)
if [ -n "$diff" ]; then
echo >&2 'ERROR: Vendor result differs. Please vendor your package with "make -f docker.Makefile vendor"'
echo "$diff"
Expand All @@ -40,24 +35,21 @@ outdated() {
echo "go-mod-outdated not found. Install with 'go install github.com/psampaz/go-mod-outdated@v0.8.0'"
exit 1
fi
(set -x ; go list -mod=vendor -mod=readonly -modfile=vendor.mod -u -m -json all | go-mod-outdated -update -direct)
(
set -x
go list -mod=vendor -mod=readonly -u -m -json all | go-mod-outdated -update -direct
)
}

case $TYP in
"init")
init
;;
"update")
init
update
;;
"validate")
init
update
validate
;;
"outdated")
init
outdated
;;
*)
Expand Down

0 comments on commit 00955f5

Please sign in to comment.