From e681b170eb67141dad3a1430ab7f23641f15fb6f Mon Sep 17 00:00:00 2001 From: Jan Safranek Date: Wed, 21 Feb 2024 18:16:04 +0100 Subject: [PATCH] Use .go-version to get Kubernetes go version Kubernetes publishes .go-version since v1.23. Use it to get Kubernete's go version instead of parsing a shell script. --- prow.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/prow.sh b/prow.sh index a27c71f3d..0af3fdcd8 100755 --- a/prow.sh +++ b/prow.sh @@ -564,7 +564,15 @@ go_version_for_kubernetes () ( local version="$2" local go_version - # We use the minimal Go version specified for each K8S release (= minimum_go_version in hack/lib/golang.sh). + # Try to get the version for .go-version + go_version="$( cat "$path/.go-version" )" + if [ "$go_version" ]; then + echo "$go_version" + return + fi + + # Fall back to hack/lib/golang.sh parsing. + # This is necessary in v1.26.0 and older Kubernetes releases that do not have .go-version. # More recent versions might also work, but we don't want to count on that. go_version="$(grep minimum_go_version= "$path/hack/lib/golang.sh" | sed -e 's/.*=go//')" if ! [ "$go_version" ]; then