Skip to content

Commit 1d60e77

Browse files
authored
Merge pull request #131 from pohly/kubernetes-1.20-tag
prow.sh: support building Kubernetes for a specific version
2 parents fe1f284 + 9f10459 commit 1d60e77

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

Diff for: prow.sh

+22-17
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,18 @@ get_versioned_variable () {
6565
echo "$value"
6666
}
6767

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+
6880
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"
6981

7082
# If we have a vendor directory, then use it. We must be careful to only
@@ -208,16 +220,7 @@ configvar CSI_PROW_DRIVER_CANARY_REGISTRY "gcr.io/k8s-staging-sig-storage" "regi
208220
# all generated files are present.
209221
#
210222
# CSI_PROW_E2E_REPO=none disables E2E testing.
211-
tag_from_version () {
212-
version="$1"
213-
shift
214-
case "$version" in
215-
latest) echo "master";;
216-
release-*) echo "$version";;
217-
*) echo "v$version";;
218-
esac
219-
}
220-
configvar CSI_PROW_E2E_VERSION "$(tag_from_version "${CSI_PROW_KUBERNETES_VERSION}")" "E2E version"
223+
configvar CSI_PROW_E2E_VERSION "$(version_to_git "${CSI_PROW_KUBERNETES_VERSION}")" "E2E version"
221224
configvar CSI_PROW_E2E_REPO "https://github.com/kubernetes/kubernetes" "E2E repo"
222225
configvar CSI_PROW_E2E_IMPORT_PATH "k8s.io/kubernetes" "E2E package"
223226

@@ -465,20 +468,22 @@ git_checkout () {
465468

466469
# This clones a repo ("https://github.com/kubernetes/kubernetes")
467470
# 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
472477
repo="$1"
473478
shift
474479
path="$1"
475480
shift
476-
branch="$1"
481+
name="$1"
477482
shift
478483

479484
parent="$(dirname "$path")"
480485
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
482487
# This is useful for local testing or when switching between different revisions in the same
483488
# repo.
484489
(cd "$path" && run git clean -fdx) || die "failed to clean $path"
@@ -567,7 +572,7 @@ start_cluster () {
567572
else
568573
type="docker"
569574
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"
571576

572577
go_version="$(go_version_for_kubernetes "${CSI_PROW_WORK}/src/kubernetes" "$version")" || die "cannot proceed without knowing Go version for Kubernetes"
573578
# Changing into the Kubernetes source code directory is a workaround for https://github.com/kubernetes-sigs/kind/issues/1910

0 commit comments

Comments
 (0)