mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-19 09:52:49 +00:00
Invoke gimme from kube::golang::verify_go_version
Defaults to ensuring .go-version is used Override the go version by setting GO_VERSION=1.x Force using the host go version with FORCE_HOST_GO=y
This commit is contained in:
parent
f6bb29c2d2
commit
fa66ec647d
@ -532,6 +532,8 @@ function kube::build::run_build_command_ex() {
|
||||
--env "KUBE_BUILD_WITH_COVERAGE=${KUBE_BUILD_WITH_COVERAGE:-}"
|
||||
--env "KUBE_BUILD_PLATFORMS=${KUBE_BUILD_PLATFORMS:-}"
|
||||
--env "KUBE_CGO_OVERRIDES=' ${KUBE_CGO_OVERRIDES[*]:-} '"
|
||||
--env "FORCE_HOST_GO=${FORCE_HOST_GO:-}"
|
||||
--env "GO_VERSION=${GO_VERSION:-}"
|
||||
--env "GOFLAGS=${GOFLAGS:-}"
|
||||
--env "GOGCFLAGS=${GOGCFLAGS:-}"
|
||||
--env "SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH:-}"
|
||||
|
@ -464,7 +464,21 @@ kube::golang::create_gopath_tree() {
|
||||
}
|
||||
|
||||
# Ensure the go tool exists and is a viable version.
|
||||
# Inputs:
|
||||
# env-var GO_VERSION is the desired go version to use, downloading it if needed (defaults to content of .go-version)
|
||||
# env-var FORCE_HOST_GO set to a non-empty value uses the go version in the $PATH and skips ensuring $GO_VERSION is used
|
||||
kube::golang::verify_go_version() {
|
||||
# default GO_VERSION to content of .go-version
|
||||
GO_VERSION="${GO_VERSION:-"$(cat "${KUBE_ROOT}/.go-version")"}"
|
||||
# only setup go if we haven't set FORCE_HOST_GO, or `go version` doesn't match GO_VERSION
|
||||
if ! ([ -n "${FORCE_HOST_GO:-}" ] || \
|
||||
(command -v go >/dev/null && [ "$(go version | cut -d' ' -f3)" = "go${GO_VERSION}" ])); then
|
||||
export GIMME_ENV_PREFIX=${GIMME_ENV_PREFIX:-"${KUBE_OUTPUT}/.gimme/envs"}
|
||||
export GIMME_VERSION_PREFIX=${GIMME_VERSION_PREFIX:-"${KUBE_OUTPUT}/.gimme/versions"}
|
||||
# eval because the output of this is shell to set PATH etc.
|
||||
eval "$("${KUBE_ROOT}/third_party/gimme/gimme" "${GO_VERSION}")"
|
||||
fi
|
||||
|
||||
if [[ -z "$(command -v go)" ]]; then
|
||||
kube::log::usage_from_stdin <<EOF
|
||||
Can't find 'go' in PATH, please fix and retry.
|
||||
|
Loading…
Reference in New Issue
Block a user