Merge pull request #124195 from bart0sh/PR139-use-downloaded-go-to-place-binaries

hacks: build main target without go in the PATH
This commit is contained in:
Kubernetes Prow Robot 2024-04-18 03:24:21 -07:00 committed by GitHub
commit f5f8db0faf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 87 additions and 90 deletions

View File

@ -635,6 +635,7 @@ kube::golang::place_bins() {
ln -s "${KUBE_OUTPUT_BIN}/${platform}" "${THIS_PLATFORM_BIN}"
fi
V=3 kube::log::status "Placing binaries for ${platform} in ${KUBE_OUTPUT_BIN}/${platform}"
local full_binpath_src="${KUBE_GOPATH}/bin${platform_src}"
if [[ -d "${full_binpath_src}" ]]; then
mkdir -p "${KUBE_OUTPUT_BIN}/${platform}"
@ -795,7 +796,7 @@ kube::golang::build_binaries_for_platform() {
fi
done
V=2 kube::log::info "Env for ${platform}: GOOS=${GOOS-} GOARCH=${GOARCH-} GOROOT=${GOROOT-} CGO_ENABLED=${CGO_ENABLED-} CC=${CC-}"
V=2 kube::log::info "Env for ${platform}: GOPATH=${GOPATH-} GOOS=${GOOS-} GOARCH=${GOARCH-} GOROOT=${GOROOT-} CGO_ENABLED=${CGO_ENABLED-} CC=${CC-}"
V=3 kube::log::info "Building binaries with GCFLAGS=${gogcflags} LDFLAGS=${goldflags}"
local -a build_args
@ -873,10 +874,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
@ -964,7 +961,7 @@ kube::golang::build_binaries() {
cat "/tmp//${platform//\//_}.build"
done
exit "${fails}"
return "${fails}"
else
for platform in "${platforms[@]}"; do
kube::log::status "Building go targets for ${platform}"
@ -974,5 +971,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