Add script to check go version and fix output directory permissions (#4907)

This commit is contained in:
Manuel Alejandro de Brito Fontes 2020-01-09 13:48:43 -03:00 committed by GitHub
parent fcd3a580d9
commit 42351d3737
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 65 additions and 13 deletions

View file

@ -154,11 +154,11 @@ push: .push-$(ARCH) ## Publish image for a particular arch.
$(DOCKER) push $(MULTI_ARCH_IMAGE):$(TAG)
.PHONY: build
build: ## Build ingress controller, debug tool and pre-stop hook.
build: check-go-version ## Build ingress controller, debug tool and pre-stop hook.
ifeq ($(USE_DOCKER), true)
@build/run-in-docker.sh \
PKG=$(PKG) \
ARCH=$(PKG) \
ARCH=$(ARCH) \
GIT_COMMIT=$(GIT_COMMIT) \
REPO_INFO=$(REPO_INFO) \
TAG=$(TAG) \
@ -169,11 +169,11 @@ else
endif
.PHONY: build-plugin
build-plugin: ## Build ingress-nginx krew plugin.
build-plugin: check-go-version ## Build ingress-nginx krew plugin.
ifeq ($(USE_DOCKER), true)
@build/run-in-docker.sh \
PKG=$(PKG) \
ARCH=$(PKG) \
ARCH=$(ARCH) \
GIT_COMMIT=$(GIT_COMMIT) \
REPO_INFO=$(REPO_INFO) \
TAG=$(TAG) \
@ -197,11 +197,11 @@ else
endif
.PHONY: test
test: ## Run go unit tests.
test: check-go-version ## Run go unit tests.
ifeq ($(USE_DOCKER), true)
@build/run-in-docker.sh \
PKG=$(PKG) \
ARCH=$(PKG) \
ARCH=$(ARCH) \
GIT_COMMIT=$(GIT_COMMIT) \
REPO_INFO=$(REPO_INFO) \
TAG=$(TAG) \
@ -222,7 +222,7 @@ else
endif
.PHONY: e2e-test
e2e-test: ## Run e2e tests (expects access to a working Kubernetes cluster).
e2e-test: check-go-version ## Run e2e tests (expects access to a working Kubernetes cluster).
@build/run-e2e-suite.sh
.PHONY: e2e-test-image
@ -230,7 +230,7 @@ e2e-test-image: e2e-test-binary ## Build image for e2e tests.
@make -C test/e2e-image
.PHONY: e2e-test-binary
e2e-test-binary: ## Build ginkgo binary for e2e tests.
e2e-test-binary: check-go-version ## Build ginkgo binary for e2e tests.
ifeq ($(USE_DOCKER), true)
@build/run-in-docker.sh \
ginkgo build ./test/e2e
@ -239,7 +239,7 @@ else
endif
.PHONY: cover
cover: ## Run go coverage unit tests.
cover: check-go-version ## Run go coverage unit tests.
@build/cover.sh
echo "Uploading coverage results..."
@curl -s https://codecov.io/bash | bash
@ -260,13 +260,13 @@ check_dead_links: ## Check if the documentation contains dead links.
--allow-redirect $(shell find $$PWD -mindepth 1 -name "*.md" -printf '%P\n' | grep -v vendor | grep -v Changelog.md)
.PHONY: dep-ensure
dep-ensure: ## Update and vendo go dependencies.
dep-ensure: check-go-version ## Update and vendo go dependencies.
go mod tidy -v
find vendor -name '*_test.go' -delete
go mod vendor
.PHONY: dev-env
dev-env: ## Starts a local Kubernetes cluster using minikube, building and deploying the ingress controller.
dev-env: check-go-version ## Starts a local Kubernetes cluster using minikube, building and deploying the ingress controller.
@USE_DOCKER=false build/dev-env.sh
.PHONY: live-docs
@ -280,7 +280,7 @@ build-docs: ## Build documentation (output in ./site directory).
@docker run --rm -v ${PWD}:/docs ingress-nginx/mkdocs build
.PHONY: misspell
misspell: ## Check for spelling errors.
misspell: check-go-version ## Check for spelling errors.
@go get github.com/client9/misspell/cmd/misspell
misspell \
-locale US \
@ -288,9 +288,13 @@ misspell: ## Check for spelling errors.
cmd/* internal/* deploy/* docs/* design/* test/* README.md
.PHONY: kind-e2e-test
kind-e2e-test: ## Run e2e tests using kind.
kind-e2e-test: check-go-version ## Run e2e tests using kind.
@test/e2e/run.sh
.PHONY: run-ingress-controller
run-ingress-controller: ## Run the ingress controller locally using a kubectl proxy connection.
@build/run-ingress-controller.sh
.PHONY: check-go-version
check-go-version:
@hack/check-go-version.sh

View file

@ -48,6 +48,9 @@ if [ ! -d "${MINIKUBE_PATH}" ]; then
MINIKUBE_VOLUME=""
fi
# create output directory as current user to avoid problem with docker.
mkdir -p "${KUBE_ROOT}/bin" "${KUBE_ROOT}/bin/${ARCH}"
docker run \
--tty \
--rm \

45
hack/check-go-version.sh Executable file
View file

@ -0,0 +1,45 @@
#!/bin/bash
# Copyright 2020 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
if [ -n "$DEBUG" ]; then
set -x
fi
set -o errexit
set -o nounset
set -o pipefail
MINIMUM_GO_VERSION=go1.13
if [[ -z "$(command -v go)" ]]; then
echo "
Can't find 'go' in PATH, please fix and retry.
See http://golang.org/doc/install for installation instructions.
"
exit 1
fi
IFS=" " read -ra go_version <<< "$(go version)"
if [[ "${MINIMUM_GO_VERSION}" != $(echo -e "${MINIMUM_GO_VERSION}\n${go_version[2]}" | sort -s -t. -k 1,1 -k 2,2n -k 3,3n | head -n1) && "${go_version[2]}" != "devel" ]]; then
echo "
Detected go version: ${go_version[*]}.
ingress-nginx requires ${MINIMUM_GO_VERSION} or greater.
Please install ${MINIMUM_GO_VERSION} or later.
"
exit 1
fi