Skip to content

Commit 6b05f0f

Browse files
committed
use new GOTOOLCHAIN env to manage go version
Should prevent go from automatically downloading newer toolchains. And ensure the specified version is used.
1 parent 227577e commit 6b05f0f

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

prow.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -425,23 +425,23 @@ die () {
425425
exit 1
426426
}
427427

428-
# Ensure that PATH has the desired version of the Go tools, then run command given as argument.
428+
# Ensure we use the desired version of the Go tools, then run command given as argument.
429429
# Empty parameter uses the already installed Go. In Prow, that version is kept up-to-date by
430430
# bumping the container image regularly.
431431
run_with_go () {
432432
local version
433433
version="$1"
434434
shift
435435

436-
if ! [ "$version" ] || go version 2>/dev/null | grep -q "go$version"; then
437-
run "$@"
438-
else
439-
if ! [ -d "${CSI_PROW_WORK}/go-$version" ]; then
440-
run curl --fail --location "https://dl.google.com/go/go$version.linux-amd64.tar.gz" | tar -C "${CSI_PROW_WORK}" -zxf - || die "installation of Go $version failed"
441-
mv "${CSI_PROW_WORK}/go" "${CSI_PROW_WORK}/go-$version"
436+
if [ "$version" ]; then
437+
version=go$version
438+
if [ "$(GOTOOLCHAIN=$version go version | cut -d' ' -f3)" != "$version" ]; then
439+
die "Please install Go 1.21+"
442440
fi
443-
PATH="${CSI_PROW_WORK}/go-$version/bin:$PATH" run "$@"
441+
else
442+
version=local
444443
fi
444+
GOTOOLCHAIN=$version run "$@"
445445
}
446446

447447
# Ensure that we have the desired version of kind.

0 commit comments

Comments
 (0)