From 00955f52ff01c08184c4a75a733725a613e763e1 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Fri, 24 Mar 2023 20:27:19 +0100 Subject: [PATCH] switch to go module 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 --- .dockerignore | 4 ---- .gitattributes | 2 -- .gitignore | 4 ---- dockerfiles/Dockerfile.vendor | 2 +- vendor.mod => go.mod | 4 ---- vendor.sum => go.sum | 0 scripts/docs/generate-man.sh | 8 +++----- scripts/docs/generate-md.sh | 6 ++---- scripts/docs/generate-yaml.sh | 6 ++---- scripts/vendor | 28 ++++++++++------------------ 10 files changed, 18 insertions(+), 46 deletions(-) rename vendor.mod => go.mod (93%) rename vendor.sum => go.sum (100%) diff --git a/.dockerignore b/.dockerignore index 57b2e28bf13b..e122c203bd1d 100644 --- a/.dockerignore +++ b/.dockerignore @@ -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 diff --git a/.gitattributes b/.gitattributes index 4f1544141aec..9dd7ef0727b3 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1 @@ Dockerfile* linguist-language=Dockerfile -vendor.mod linguist-language=Go-Module -vendor.sum linguist-language=Go-Checksums diff --git a/.gitignore b/.gitignore index a7462428a4e9..ea76bfde5183 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/dockerfiles/Dockerfile.vendor b/dockerfiles/Dockerfile.vendor index 618ae1479d49..d9a3a858a755 100644 --- a/dockerfiles/Dockerfile.vendor +++ b/dockerfiles/Dockerfile.vendor @@ -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 diff --git a/vendor.mod b/go.mod similarity index 93% rename from vendor.mod rename to go.mod index ef0a078bee6e..bdb8a717d76c 100644 --- a/vendor.mod +++ b/go.mod @@ -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 ( diff --git a/vendor.sum b/go.sum similarity index 100% rename from vendor.sum rename to go.sum diff --git a/scripts/docs/generate-man.sh b/scripts/docs/generate-man.sh index 6afed3fa8708..7fd63ae4b4cb 100755 --- a/scripts/docs/generate-man.sh +++ b/scripts/docs/generate-man.sh @@ -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 diff --git a/scripts/docs/generate-md.sh b/scripts/docs/generate-md.sh index 1d155a1cef77..16a5238481f9 100755 --- a/scripts/docs/generate-md.sh +++ b/scripts/docs/generate-md.sh @@ -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 diff --git a/scripts/docs/generate-yaml.sh b/scripts/docs/generate-yaml.sh index 4d0006e43e79..20833b91ca98 100755 --- a/scripts/docs/generate-yaml.sh +++ b/scripts/docs/generate-yaml.sh @@ -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 diff --git a/scripts/vendor b/scripts/vendor index 687e57cb0531..f9002b32cf1d 100755 --- a/scripts/vendor +++ b/scripts/vendor @@ -13,21 +13,16 @@ if [ -z "$TYP" ]; then usage fi -init() { - # create dummy go.mod, see comment in vendor.mod - cat > go.mod <&2 'ERROR: Vendor result differs. Please vendor your package with "make -f docker.Makefile vendor"' echo "$diff" @@ -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 ;; *)