hacks: build main target without go in the PATH

`make` is able to build project binaries, but fails with
error `hack/lib/golang.sh: line 455: go: command not found`
trying to place them if go binary is not in the PATH.
This happens because kube::golang::place_bins uses different
environment than kube::golang::build_binaries.

Setting up an one environment for both `kube::golang::place_bins`
and `kube::golang::build_binaries` should solve this issue and allow
default make target to fully work without go binary in the PATH.
This commit is contained in:
Ed Bartosh 2024-04-05 17:36:57 +03:00
parent d9c54f69d4
commit 91099aca72
2 changed files with 85 additions and 89 deletions

View File

@ -873,10 +873,6 @@ kube::golang::get_physmem() {
# KUBE_BUILD_PLATFORMS - Incoming variable of targets to build for. If unset
# then just the host architecture is built.
kube::golang::build_binaries() {
# Create a sub-shell so that we don't pollute the outer environment
(
# Check for `go` binary and set ${GOPATH}.
kube::golang::setup_env
V=2 kube::log::info "Go version: $(GOFLAGS='' go version)"
local host_platform
@ -974,5 +970,4 @@ kube::golang::build_binaries() {
)
done
fi
)
}

View File

@ -24,5 +24,6 @@ KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/../..
KUBE_VERBOSE="${KUBE_VERBOSE:-1}"
source "${KUBE_ROOT}/hack/lib/init.sh"
kube::golang::setup_env
kube::golang::build_binaries "$@"
kube::golang::place_bins