File tree Expand file tree Collapse file tree 9 files changed +33
-11
lines changed Expand file tree Collapse file tree 9 files changed +33
-11
lines changed Original file line number Diff line number Diff line change @@ -43,8 +43,12 @@ export KUBE_ROOT
43
43
export PATH=${GOPATH} /bin:${PWD} /third_party/etcd:/usr/local/go/bin:${PATH}
44
44
45
45
# Install tools we need
46
- go -C " ${KUBE_ROOT} /hack/tools" install github.com/cespare/prettybench
47
- go -C " ${KUBE_ROOT} /hack/tools" install gotest.tools/gotestsum
46
+ hack_tools_gotoolchain=" ${GOTOOLCHAIN:- } "
47
+ if [ -n " ${KUBE_HACK_TOOLS_GOTOOLCHAIN:- } " ]; then
48
+ hack_tools_gotoolchain=" ${KUBE_HACK_TOOLS_GOTOOLCHAIN} " ;
49
+ fi
50
+ GOTOOLCHAIN=" ${hack_tools_gotoolchain} " go -C " ${KUBE_ROOT} /hack/tools" install github.com/cespare/prettybench
51
+ GOTOOLCHAIN=" ${hack_tools_gotoolchain} " go -C " ${KUBE_ROOT} /hack/tools" install gotest.tools/gotestsum
48
52
49
53
# Disable the Go race detector.
50
54
export KUBE_RACE=" "
Original file line number Diff line number Diff line change @@ -27,7 +27,11 @@ set -o xtrace
27
27
export PATH=${GOPATH} /bin:${PWD} /third_party/etcd:/usr/local/go/bin:${PATH}
28
28
29
29
# Install tools we need
30
- go -C " ./hack/tools" install gotest.tools/gotestsum
30
+ hack_tools_gotoolchain=" ${GOTOOLCHAIN:- } "
31
+ if [ -n " ${KUBE_HACK_TOOLS_GOTOOLCHAIN:- } " ]; then
32
+ hack_tools_gotoolchain=" ${KUBE_HACK_TOOLS_GOTOOLCHAIN} " ;
33
+ fi
34
+ GOTOOLCHAIN=" ${hack_tools_gotoolchain} " go -C " ./hack/tools" install gotest.tools/gotestsum
31
35
32
36
# Disable coverage report
33
37
export KUBE_COVER=" n"
Original file line number Diff line number Diff line change @@ -607,12 +607,26 @@ kube::golang::setup_env() {
607
607
kube::golang::internal::verify_go_version
608
608
}
609
609
610
+ # kube::golang::hack_tools_gotoolchain outputs the value to use for $GOTOOLCHAIN,
611
+ # using $KUBE_HACK_TOOLS_GOTOOLCHAIN if set, falling back to $GOTOOLCHAIN if set,
612
+ # or outputting the empty string.
613
+ #
614
+ # Use this when installing / building tools specified in the hack/tools module:
615
+ # GOTOOLCHAIN="$(kube::golang::hack_tools_gotoolchain)" go install ...
616
+ kube::golang::hack_tools_gotoolchain () {
617
+ local hack_tools_gotoolchain=" ${GOTOOLCHAIN:- } "
618
+ if [ -n " ${KUBE_HACK_TOOLS_GOTOOLCHAIN:- } " ]; then
619
+ hack_tools_gotoolchain=" ${KUBE_HACK_TOOLS_GOTOOLCHAIN} " ;
620
+ fi
621
+ echo -n " ${hack_tools_gotoolchain} "
622
+ }
623
+
610
624
kube::golang::setup_gomaxprocs () {
611
625
# GOMAXPROCS by default does not reflect the number of cpu(s) available
612
626
# when running in a container, please see https://github.com/golang/go/issues/33803
613
627
if [[ -z " ${GOMAXPROCS:- } " ]]; then
614
628
if ! command -v ncpu > /dev/null 2>&1 ; then
615
- go -C " ${KUBE_ROOT} /hack/tools" install ./ncpu || echo " Will not automatically set GOMAXPROCS"
629
+ GOTOOLCHAIN= " $( kube::golang::hack_tools_gotoolchain ) " go -C " ${KUBE_ROOT} /hack/tools" install ./ncpu || echo " Will not automatically set GOMAXPROCS"
616
630
fi
617
631
if command -v ncpu > /dev/null 2>&1 ; then
618
632
GOMAXPROCS=$( ncpu)
Original file line number Diff line number Diff line change @@ -182,7 +182,7 @@ junitFilenamePrefix() {
182
182
installTools () {
183
183
if ! command -v gotestsum > /dev/null 2>&1 ; then
184
184
kube::log::status " gotestsum not found; installing from ./hack/tools"
185
- go -C " ${KUBE_ROOT} /hack/tools" install gotest.tools/gotestsum
185
+ GOTOOLCHAIN= " $( kube::golang::hack_tools_gotoolchain ) " go -C " ${KUBE_ROOT} /hack/tools" install gotest.tools/gotestsum
186
186
fi
187
187
188
188
if ! command -v prune-junit-xml > /dev/null 2>&1 ; then
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ source "${KUBE_ROOT}/hack/lib/init.sh"
27
27
kube::golang::setup_env
28
28
29
29
echo ' installing mockery'
30
- go -C " ${KUBE_ROOT} /hack/tools" install github.com/vektra/mockery/v2
30
+ GOTOOLCHAIN= " $( kube::golang::hack_tools_gotoolchain ) " go -C " ${KUBE_ROOT} /hack/tools" install github.com/vektra/mockery/v2
31
31
32
32
function git_grep() {
33
33
git grep --untracked --exclude-standard \
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ PATH="${GOBIN}:${PATH}"
36
36
37
37
# Install golangci-lint
38
38
echo ' installing net parser converter'
39
- go -C " ${KUBE_ROOT} /hack/tools" install github.com/aojea/sloppy-netparser
39
+ GOTOOLCHAIN= " $( kube::golang::hack_tools_gotoolchain ) " go -C " ${KUBE_ROOT} /hack/tools" install github.com/aojea/sloppy-netparser
40
40
41
41
cd " ${KUBE_ROOT} "
42
42
Original file line number Diff line number Diff line change @@ -121,12 +121,12 @@ done
121
121
122
122
# Install golangci-lint
123
123
echo " installing golangci-lint and logcheck plugin from hack/tools into ${GOBIN} "
124
- go -C " ${KUBE_ROOT} /hack/tools" install github.com/golangci/golangci-lint/cmd/golangci-lint
124
+ GOTOOLCHAIN= " $( kube::golang::hack_tools_gotoolchain ) " go -C " ${KUBE_ROOT} /hack/tools" install github.com/golangci/golangci-lint/cmd/golangci-lint
125
125
if [ " ${golangci_config} " ]; then
126
126
# This cannot be used without a config.
127
127
# This uses `go build` because `go install -buildmode=plugin` doesn't work
128
128
# (on purpose: https://github.com/golang/go/issues/64964).
129
- go -C " ${KUBE_ROOT} /hack/tools" build -o " ${GOBIN} /logcheck.so" -buildmode=plugin sigs.k8s.io/logtools/logcheck/plugin
129
+ GOTOOLCHAIN= " $( kube::golang::hack_tools_gotoolchain ) " go -C " ${KUBE_ROOT} /hack/tools" build -o " ${GOBIN} /logcheck.so" -buildmode=plugin sigs.k8s.io/logtools/logcheck/plugin
130
130
fi
131
131
132
132
if [ " ${golangci_config} " ]; then
Original file line number Diff line number Diff line change @@ -27,6 +27,6 @@ source "${KUBE_ROOT}/hack/lib/init.sh"
27
27
28
28
kube::golang::setup_env
29
29
30
- go -C " ${KUBE_ROOT} /hack/tools" install ./publishing-verifier
30
+ GOTOOLCHAIN= " $( kube::golang::hack_tools_gotoolchain ) " go -C " ${KUBE_ROOT} /hack/tools" install ./publishing-verifier
31
31
32
32
publishing-verifier " ${KUBE_ROOT} "
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ export GOBIN="${KUBE_OUTPUT_BIN}"
32
32
PATH=" ${GOBIN} :${PATH} "
33
33
34
34
# Install tools we need
35
- go -C " ${KUBE_ROOT} /hack/tools" install github.com/client9/misspell/cmd/misspell
35
+ GOTOOLCHAIN= " $( kube::golang::hack_tools_gotoolchain ) " go -C " ${KUBE_ROOT} /hack/tools" install github.com/client9/misspell/cmd/misspell
36
36
37
37
# Spell checking
38
38
# All the skipping files are defined in hack/.spelling_failures
You can’t perform that action at this time.
0 commit comments