Allow override of CGO_ENABLED=0

When building inside a docker container, we fail to pass along enough
information for KUBE_CGO_OVERRIDES. The original PR was geared towards
building the binary from the command line

- dca376a03e
- e4ded2b3ec

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
This commit is contained in:
Davanum Srinivas 2021-08-05 10:44:16 -04:00
parent 2b06890e12
commit af2129b77d
No known key found for this signature in database
GPG Key ID: 80D83A796103BF59
2 changed files with 3 additions and 0 deletions

View File

@ -519,6 +519,7 @@ function kube::build::run_build_command_ex() {
--env "KUBE_VERBOSE=${KUBE_VERBOSE}"
--env "KUBE_BUILD_WITH_COVERAGE=${KUBE_BUILD_WITH_COVERAGE:-}"
--env "KUBE_BUILD_PLATFORMS=${KUBE_BUILD_PLATFORMS:-}"
--env "KUBE_CGO_OVERRIDES=' ${KUBE_CGO_OVERRIDES[*]:-} '"
--env "GOFLAGS=${GOFLAGS:-}"
--env "GOGCFLAGS=${GOGCFLAGS:-}"
--env "SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH:-}"

View File

@ -716,6 +716,7 @@ kube::golang::build_binaries_for_platform() {
-ldflags "${goldflags:-}"
-tags "${gotags:-}"
)
V=1 kube::log::info "> static build CGO_ENABLED=0: ${statics[*]}"
CGO_ENABLED=0 kube::golang::build_some_binaries "${statics[@]}"
fi
@ -728,6 +729,7 @@ kube::golang::build_binaries_for_platform() {
-buildmode pie
-tags "${gotags:-}"
)
V=1 kube::log::info "> non-static build: ${nonstatics[*]}"
kube::golang::build_some_binaries "${nonstatics[@]}"
fi