You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
prow.sh: support building Kubernetes for a specific version
Checking out the Kubernetes source code only supported
branches (master, release-1.20) but not a version (like 1.20.0)
because tags need a leading "v". "git clone --branch" (despite the
name) is able to fetch a tag.
Copy file name to clipboardExpand all lines: prow.sh
+22-17
Original file line number
Diff line number
Diff line change
@@ -65,6 +65,18 @@ get_versioned_variable () {
65
65
echo"$value"
66
66
}
67
67
68
+
# This takes a version string like CSI_PROW_KUBERNETES_VERSION and
69
+
# maps it to the corresponding git tag, branch or commit.
70
+
version_to_git () {
71
+
version="$1"
72
+
shift
73
+
case"$version"in
74
+
latest) echo"master";;
75
+
release-*) echo"$version";;
76
+
*) echo"v$version";;
77
+
esac
78
+
}
79
+
68
80
configvar CSI_PROW_BUILD_PLATFORMS "linux amd64; windows amd64 .exe; linux ppc64le -ppc64le; linux s390x -s390x; linux arm64 -arm64""Go target platforms (= GOOS + GOARCH) and file suffix of the resulting binaries"
69
81
70
82
# If we have a vendor directory, then use it. We must be careful to only
# This clones a repo ("https://github.com/kubernetes/kubernetes")
467
470
# in a certain location ("$GOPATH/src/k8s.io/kubernetes") at
468
-
# a the head of a specific branch (i.e., release-1.13, master).
469
-
# The directory cannot exist.
470
-
git_clone_branch () {
471
-
local repo path branch parent
471
+
# a the head of a specific branch (i.e., release-1.13, master),
472
+
# tag (v1.20.0) or commit.
473
+
#
474
+
# The directory must not exist.
475
+
git_clone () {
476
+
local repo path name parent
472
477
repo="$1"
473
478
shift
474
479
path="$1"
475
480
shift
476
-
branch="$1"
481
+
name="$1"
477
482
shift
478
483
479
484
parent="$(dirname "$path")"
480
485
mkdir -p "$parent"
481
-
(cd "$parent"&& run git clone --single-branch --branch "$branch""$repo""$path") || die "cloning $repo" failed
486
+
(cd "$parent"&& run git clone --single-branch --branch "$name""$repo""$path") || die "cloning $repo" failed
482
487
# This is useful for local testing or when switching between different revisions in the same
483
488
# repo.
484
489
(cd "$path"&& run git clean -fdx) || die "failed to clean $path"
@@ -567,7 +572,7 @@ start_cluster () {
567
572
else
568
573
type="docker"
569
574
fi
570
-
git_clone_branch https://github.com/kubernetes/kubernetes "${CSI_PROW_WORK}/src/kubernetes""$version"|| die "checking out Kubernetes $version failed"
575
+
git_clone https://github.com/kubernetes/kubernetes "${CSI_PROW_WORK}/src/kubernetes""$(version_to_git "$version")"|| die "checking out Kubernetes $version failed"
571
576
572
577
go_version="$(go_version_for_kubernetes "${CSI_PROW_WORK}/src/kubernetes""$version")"|| die "cannot proceed without knowing Go version for Kubernetes"
573
578
# Changing into the Kubernetes source code directory is a workaround for https://github.com/kubernetes-sigs/kind/issues/1910
0 commit comments