Skip to content

Commit

Permalink
Remove vendor directory and enable go modules
Browse files Browse the repository at this point in the history
  • Loading branch information
aledbf committed Jun 24, 2020
1 parent 14acc18 commit 93bf818
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 32 deletions.
9 changes: 0 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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<target>\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)

Expand Down Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions build/build-plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 0 additions & 5 deletions build/cover.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion build/run-in-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}" \
Expand Down
6 changes: 0 additions & 6 deletions build/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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")
20 changes: 12 additions & 8 deletions hack/update-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion test/e2e/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 93bf818

Please sign in to comment.