Call verify_go_version at the END of setup_env

Prior to this it would download Go, setup the environment, then (maybe)
download Go again.

I renamed verify_go_version to be internal and fixed all callers.
This commit is contained in:
Tim Hockin
2024-01-06 15:20:11 -08:00
parent e84adf611f
commit d61f299614
18 changed files with 8 additions and 20 deletions

View File

@@ -504,7 +504,7 @@ kube::golang::set_platform_envs() {
# 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() {
kube::golang::internal::verify_go_version() {
# default GO_VERSION to content of .go-version
GO_VERSION="${GO_VERSION:-"$(cat "${KUBE_ROOT}/.go-version")"}"
if [ "${GOTOOLCHAIN:-auto}" != 'auto' ]; then
@@ -557,8 +557,6 @@ EOF
# env-var GOBIN is unset (we want binaries in a predictable place)
# env-var PATH includes the local GOPATH
kube::golang::setup_env() {
kube::golang::verify_go_version
# Even in module mode, we need to set GOPATH for `go build` and `go install`
# to work. We build various tools (usually via `go install`) from a lot of
# scripts.
@@ -588,6 +586,10 @@ kube::golang::setup_env() {
# Explicitly turn on modules.
export GO111MODULE=on
# This may try to download our specific Go version. Do it last so it uses
# the above-configured environment.
kube::golang::internal::verify_go_version
}
kube::golang::setup_gomaxprocs() {