From 93bf81821412e75ac7e8eede283e117afbd116ec Mon Sep 17 00:00:00 2001 From: Manuel Alejandro de Brito Fontes Date: Tue, 23 Jun 2020 20:55:08 -0400 Subject: [PATCH] Remove vendor directory and enable go modules --- Makefile | 9 --------- build/build-plugin.sh | 2 -- build/cover.sh | 5 ----- build/run-in-docker.sh | 1 - build/test.sh | 6 ------ hack/update-codegen.sh | 20 ++++++++++++-------- test/e2e/run.sh | 2 +- 7 files changed, 13 insertions(+), 32 deletions(-) diff --git a/Makefile b/Makefile index f2653c8dd1..d35c98d1ce 100644 --- a/Makefile +++ b/Makefile @@ -65,9 +65,6 @@ BASE_IMAGE ?= quay.io/kubernetes-ingress-controller/nginx:e3c49c52f4b74fe47ad65d GOARCH=$(ARCH) -# use vendor directory instead of go modules https://github.com/golang/go/wiki/Modules -GO111MODULE=off - help: ## Display this help @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) @@ -189,12 +186,6 @@ check_dead_links: ## Check if the documentation contains dead links. --allow-dupe \ --allow-redirect $(shell find $$PWD -mindepth 1 -name "*.md" -printf '%P\n' | grep -v vendor | grep -v Changelog.md) -.PHONY: dep-ensure -dep-ensure: check-go-version ## Update and vendo go dependencies. - GO111MODULE=on go mod tidy -v - find vendor -name '*_test.go' -delete - GO111MODULE=on go mod vendor - .PHONY: dev-env dev-env: check-go-version ## Starts a local Kubernetes cluster using kind, building and deploying the ingress controller. @build/dev-env.sh diff --git a/build/build-plugin.sh b/build/build-plugin.sh index ad8346abef..d404e5e269 100755 --- a/build/build-plugin.sh +++ b/build/build-plugin.sh @@ -44,8 +44,6 @@ if [ "$missing" = true ]; then fi export CGO_ENABLED=0 -# use vendor directory instead of go modules https://github.com/golang/go/wiki/Modules -export GO111MODULE=off release=cmd/plugin/release diff --git a/build/cover.sh b/build/cover.sh index 38985cd118..17b5be3b1d 100755 --- a/build/cover.sh +++ b/build/cover.sh @@ -27,11 +27,6 @@ if [ -z "${PKG}" ]; then exit 1 fi -export CGO_ENABLED=1 -export GODEBUG=netdns=cgo+2 -# use vendor directory instead of go modules https://github.com/golang/go/wiki/Modules -export GO111MODULE=off - rm -rf coverage.txt for d in $(go list "${PKG}/..." | grep -v vendor | grep -v '/test/e2e' | grep -v images); do t=$(date +%s); diff --git a/build/run-in-docker.sh b/build/run-in-docker.sh index 76e930f8c5..47f4ab4722 100755 --- a/build/run-in-docker.sh +++ b/build/run-in-docker.sh @@ -56,7 +56,6 @@ docker run \ --rm \ ${DOCKER_OPTS} \ -e GOCACHE="/go/src/${PKG}/.cache" \ - -e GO111MODULE=off \ -e DIND_TASKS=0 \ -v "${HOME}/.kube:${HOME}/.kube" \ -v "${KUBE_ROOT}:/go/src/${PKG}" \ diff --git a/build/test.sh b/build/test.sh index 07a24ce967..bb7ccdb7e4 100755 --- a/build/test.sh +++ b/build/test.sh @@ -28,11 +28,5 @@ if [ -z "${PKG}" ]; then exit 1 fi -# enabled to use host dns resolver -export CGO_ENABLED=1 -export GODEBUG=netdns=cgo+2 -# use vendor directory instead of go modules https://github.com/golang/go/wiki/Modules -export GO111MODULE=off - go test -v \ $(go list "${PKG}/..." | grep -v vendor | grep -v '/test/e2e' | grep -v images | grep -v "docs/examples") diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index d86180bd89..2d8e0ed508 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -18,10 +18,17 @@ set -o errexit set -o nounset set -o pipefail -export GO111MODULE=off - SCRIPT_ROOT=$(dirname ${BASH_SOURCE})/.. -CODEGEN_PKG=${CODEGEN_PKG:-$(cd "${SCRIPT_ROOT}"; ls -d -1 ./vendor/k8s.io/code-generator 2>/dev/null || echo ../code-generator)} +CODEGEN_VERSION=$(grep 'k8s.io/code-generator' go.sum | awk '{print $2}' | sed 's/\/go.mod//g' | head -1) +CODEGEN_PKG=$(echo `go env GOPATH`"/pkg/mod/k8s.io/code-generator@${CODEGEN_VERSION}") + +if [[ ! -d ${CODEGEN_PKG} ]]; then + echo "${CODEGEN_PKG} is missing. Running 'go mod download'." + go mod download +fi + +# Ensure we can execute. +chmod +x ${CODEGEN_PKG}/generate-groups.sh # generate the code with: # --output-base because this script should also be able to run inside the vendor dir of @@ -31,11 +38,8 @@ CODEGEN_PKG=${CODEGEN_PKG:-$(cd "${SCRIPT_ROOT}"; ls -d -1 ./vendor/k8s.io/code- # k8s.io/ingress-nginx/pkg/client k8s.io/ingress-nginx/pkg/apis \ # nginxingress:v1alpha1 \ # --output-base "$(dirname ${BASH_SOURCE})/../../.." -mkdir -p ${CODEGEN_PKG}/hack -cp ${SCRIPT_ROOT}/hack/boilerplate/boilerplate.go.txt ${CODEGEN_PKG}/hack/boilerplate.go.txt -chmod +x ${CODEGEN_PKG}/*.sh - ${CODEGEN_PKG}/generate-groups.sh "deepcopy" \ k8s.io/ingress-nginx/internal k8s.io/ingress-nginx/internal \ .:ingress \ - --output-base "$(dirname ${BASH_SOURCE})/../../.." + --output-base "$(dirname ${BASH_SOURCE})/../../.." \ + --go-header-file ${SCRIPT_ROOT}/hack/boilerplate/boilerplate.go.txt \ No newline at end of file diff --git a/test/e2e/run.sh b/test/e2e/run.sh index 25199c328f..636a376f48 100755 --- a/test/e2e/run.sh +++ b/test/e2e/run.sh @@ -83,7 +83,7 @@ export EXIT_CODE=-1 echo " make -C ${DIR}/../../ clean-image build image make -C ${DIR}/../e2e-image image -make -C ${DIR}/../../images/fastcgi-helloserver/ GO111MODULE=\"on\" build image +make -C ${DIR}/../../images/fastcgi-helloserver/ build image make -C ${DIR}/../../images/httpbin/ image make -C ${DIR}/../../images/echo/ image make -C ${DIR}/../../images/cfssl/ image