diff --git a/.gitignore b/.gitignore index 8272f4394..e5c8a8a78 100644 --- a/.gitignore +++ b/.gitignore @@ -18,4 +18,3 @@ hack/tls-setup/certs /vendor *.bak - diff --git a/Documentation/dl-build.md b/Documentation/dl-build.md index 7b79951fa..698af26db 100644 --- a/Documentation/dl-build.md +++ b/Documentation/dl-build.md @@ -22,7 +22,7 @@ $ cd etcd $ ./build ``` -To build a vendored `etcd` from the `master` branch via `go get`: +To build a modularized `etcd` from the `master` branch via `go get`: ```sh # GOPATH should be set diff --git a/Makefile b/Makefile index 86cbc7fd5..0d2211817 100644 --- a/Makefile +++ b/Makefile @@ -23,11 +23,9 @@ clean: rm -f ./*.coverprofile rm -f ./*.log rm -f ./bin/Dockerfile-release - rm -rf ./bin/*.etcd + rm -rf ./bin/etcd* rm -rf ./default.etcd rm -rf ./tests/e2e/default.etcd - rm -rf ./gopath - rm -rf ./gopath.proto rm -rf ./release rm -f ./snapshot/localhost:* rm -f ./tools/etcd-dump-metrics/localhost:* diff --git a/client/README.md b/client/README.md index 5d8ecad11..5ecb67820 100644 --- a/client/README.md +++ b/client/README.md @@ -4,7 +4,7 @@ etcd/client is the Go client library for etcd. [![GoDoc](https://godoc.org/go.etcd.io/etcd/client?status.png)](https://godoc.org/go.etcd.io/etcd/client) -For full compatibility, it is recommended to vendor builds using etcd's vendored packages, using tools like `golang/dep`, as in [vendor directories](https://golang.org/cmd/go/#hdr-Vendor_Directories). +For full compatibility, it is recommended to install released versions of clients using go modules. ## Install diff --git a/clientv3/README.md b/clientv3/README.md index 6c6fe7c67..d35849221 100644 --- a/clientv3/README.md +++ b/clientv3/README.md @@ -41,7 +41,7 @@ if err != nil { // use the response ``` -For full compatibility, it is recommended to vendor builds using etcd's vendored packages, using tools like `golang/dep`, as in [vendor directories](https://golang.org/cmd/go/#hdr-Vendor_Directories). +For full compatibility, it is recommended to install released versions of clients using go modules. ## Error Handling diff --git a/scripts/install_tool.sh b/scripts/install_tool.sh new file mode 100755 index 000000000..05a788825 --- /dev/null +++ b/scripts/install_tool.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +# Usage ./install_tool.sh {go_module} +# +# Install given tool and makes it available on $PATH (assuming standard config), +# without modification to vendor or go.mod file. +# +# When https://github.com/golang/go/issues/40276 is implemented, usage +# of this script should get replaced by pure: +# +# go install {go_module}@latest +# +set -e + +>&2 echo "installing: ${1}" +( + cd "$(mktemp -d)" + GO111MODULE=on go get "$1" +) diff --git a/scripts/updatebom.sh b/scripts/updatebom.sh index 210e0e960..d479abb86 100755 --- a/scripts/updatebom.sh +++ b/scripts/updatebom.sh @@ -7,10 +7,7 @@ if ! [[ "$0" =~ scripts/updatebom.sh ]]; then exit 255 fi -export GO111MODULE=off # Don't add BOM tool to etcd go.mod -echo "installing 'bill-of-materials.json'" -go get -v -u github.com/coreos/license-bill-of-materials -export GO111MODULE=on +./scripts/install_tool.sh github.com/coreos/license-bill-of-materials echo "generating bill-of-materials.json" license-bill-of-materials \ diff --git a/scripts/updatedep.sh b/scripts/updatedep.sh index 46ddac980..75adc050f 100755 --- a/scripts/updatedep.sh +++ b/scripts/updatedep.sh @@ -13,10 +13,16 @@ if [ -d "gopath.proto" ]; then exit 255 fi -if [[ $(go version) != "go version go1.14"* ]]; then +if [[ $(go version) < "go version go1.14" ]]; then echo "expect Go 1.14+, got:" "$(go version)" exit 255 fi GO111MODULE=on go mod tidy -v GO111MODULE=on go mod vendor -v + +RED='\033[0;31m' +NC='\033[0m' # No Color +echo -e "\n${RED} WARNING: In etcd >=3.5 we use go modules rather than vendoring" +echo -e "${RED} Please refactor your logic to depend on modules directly.${NC}" + diff --git a/test b/test index 247aa389b..82c17118c 100755 --- a/test +++ b/test @@ -462,7 +462,7 @@ function govet_shadow_pass { # shellcheck disable=SC2206 fmtpkgs=($fmtpkgs) # Golang 1.12 onwards the experimental -shadow option is no longer available with go vet - go get -v golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow + ./scripts/install_tool.sh golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow export PATH=${GOPATH}/bin:${PATH} shadow_tool=$(which shadow) vetRes=$(go vet -all -vettool="${shadow_tool}" "${TEST[@]}")