mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
scripts: default to using .go-version's version for tests and builds
Additionally, provide ability to opt-out of the .go-version and use a custom one via env vars: FORCE_HOST_GO and GO_VERSION. Signed-off-by: Madhav Jivrajani <madhav.jiv@gmail.com>
This commit is contained in:
parent
474031588a
commit
3c990bc43b
@ -384,3 +384,27 @@ function git_assert_branch_in_sync {
|
||||
log_warning "Cannot verify consistency with the origin, as git is on detached branch."
|
||||
fi
|
||||
}
|
||||
|
||||
# The version present in the .go-verion is the default version that test and build scripts will use.
|
||||
# However, it is possible to control the version that should be used with the help of env vars:
|
||||
# - FORCE_HOST_GO: if set to a non-empty value, use the version of go installed in system's $PATH.
|
||||
# - GO_VERSION: desired version of go to be used, might differ from what is present in .go-version.
|
||||
# If empty, the value defaults to the version in .go-version.
|
||||
function determine_go_version {
|
||||
# Borrowing from how Kubernetes does this:
|
||||
# https://github.com/kubernetes/kubernetes/blob/17854f0e0a153b06f9d0db096e2cd8ab2fa89c11/hack/lib/golang.sh#L510-L520
|
||||
#
|
||||
# default GO_VERSION to content of .go-version
|
||||
GO_VERSION="${GO_VERSION:-"$(cat "${ETCD_ROOT_DIR}/.go-version")"}"
|
||||
if [ "${GOTOOLCHAIN:-auto}" != 'auto' ]; then
|
||||
# no-op, just respect GOTOOLCHAIN
|
||||
:
|
||||
elif [ -n "${FORCE_HOST_GO:-}" ]; then
|
||||
export GOTOOLCHAIN='local'
|
||||
else
|
||||
GOTOOLCHAIN="go${GO_VERSION}"
|
||||
export GOTOOLCHAIN
|
||||
fi
|
||||
}
|
||||
|
||||
determine_go_version
|
||||
|
Loading…
x
Reference in New Issue
Block a user