add go version check
Signed-off-by: lihanbo <lihanbo2@huawei.com>
This commit is contained in:
parent
c2030ca639
commit
064db4123b
|
@ -37,8 +37,10 @@ sed -i'' -e "s#k8s.gcr.io#registry.aliyuncs.com/google_containers#g" artifacts/d
|
||||||
sed -i'' -e "s#k8s.gcr.io#registry.aliyuncs.com/google_containers#g" artifacts/deploy/kube-controller-manager.yaml
|
sed -i'' -e "s#k8s.gcr.io#registry.aliyuncs.com/google_containers#g" artifacts/deploy/kube-controller-manager.yaml
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Make sure go exists
|
# Make sure go exists and the go version is a viable version.
|
||||||
util::cmd_must_exist "go"
|
util::cmd_must_exist "go"
|
||||||
|
util::verify_go_version
|
||||||
|
|
||||||
# install kind and kubectl
|
# install kind and kubectl
|
||||||
kind_version=v0.11.1
|
kind_version=v0.11.1
|
||||||
if util::cmd_exist kind; then
|
if util::cmd_exist kind; then
|
||||||
|
|
|
@ -4,7 +4,10 @@ set -o errexit
|
||||||
set -o nounset
|
set -o nounset
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
# TODO(RainbowMango): checks if the Go version is greater than the minimum go version that we requires.
|
REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
||||||
|
source "${REPO_ROOT}"/hack/util.sh
|
||||||
|
|
||||||
|
util::verify_go_version
|
||||||
|
|
||||||
echo "vendor: running 'go mod vendor'"
|
echo "vendor: running 'go mod vendor'"
|
||||||
go mod vendor
|
go mod vendor
|
||||||
|
|
13
hack/util.sh
13
hack/util.sh
|
@ -15,6 +15,8 @@ KARMADA_SCHEDULER_LABEL="karmada-scheduler"
|
||||||
KARMADA_WEBHOOK_LABEL="karmada-webhook"
|
KARMADA_WEBHOOK_LABEL="karmada-webhook"
|
||||||
AGENT_POD_LABEL="karmada-agent"
|
AGENT_POD_LABEL="karmada-agent"
|
||||||
|
|
||||||
|
MIN_Go_VERSION=go1.16.0
|
||||||
|
|
||||||
# This function installs a Go tools by 'go get' command.
|
# This function installs a Go tools by 'go get' command.
|
||||||
# Parameters:
|
# Parameters:
|
||||||
# - $1: package name, such as "sigs.k8s.io/controller-tools/cmd/controller-gen"
|
# - $1: package name, such as "sigs.k8s.io/controller-tools/cmd/controller-gen"
|
||||||
|
@ -53,6 +55,17 @@ function util::cmd_must_exist {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function util::verify_go_version {
|
||||||
|
local go_version
|
||||||
|
IFS=" " read -ra go_version <<< "$(GOFLAGS='' go version)"
|
||||||
|
if [[ "${MIN_Go_VERSION}" != $(echo -e "${MIN_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[*]}."
|
||||||
|
echo "Karmada requires ${MIN_Go_VERSION} or greater."
|
||||||
|
echo "Please install ${MIN_Go_VERSION} or later."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# util::cmd_must_exist_cfssl downloads cfssl/cfssljson if they do not already exist in PATH
|
# util::cmd_must_exist_cfssl downloads cfssl/cfssljson if they do not already exist in PATH
|
||||||
function util::cmd_must_exist_cfssl {
|
function util::cmd_must_exist_cfssl {
|
||||||
CFSSL_VERSION=${1}
|
CFSSL_VERSION=${1}
|
||||||
|
|
Loading…
Reference in New Issue