@@ -34,6 +34,41 @@ capi:buildDockerImages () {
34
34
fi
35
35
}
36
36
37
+ # k8s::prepareKindestImagesVariables defaults the environment variables KUBERNETES_VERSION,
38
+ # KUBERNETES_VERSION_UPGRADE_TO and KUBERNETES_VERSION_LATEST_CI depending on what
39
+ # is set in GINKGO_FOCUS.
40
+ # Note: We do this to ensure that the kindest/node image gets built if it does
41
+ # not already exist, e.g. for pre-releases, but only if necessary.
42
+ k8s::prepareKindestImagesVariables () {
43
+ # Always default KUBERNETES_VERSION to the value in the e2e config.
44
+
45
+ if [[ ${GINKGO_FOCUS:- } == * " K8s-Install-ci-latest" * ]]; then
46
+ # If the test focuses on [K8s-Install-ci-latest], only default KUBERNETES_VERSION_LATEST_CI
47
+ # to the value in the e2e config and only if it is not set.
48
+ # Note: We do this because we want to specify KUBERNETES_VERSION_LATEST_CI *only* in the e2e config.
49
+ if [[ -z " ${KUBERNETES_VERSION_LATEST_CI:- } " ]]; then
50
+ KUBERNETES_VERSION_LATEST_CI=$( grep KUBERNETES_VERSION_LATEST_CI: < " $E2E_CONF_FILE " | awk -F' "' ' { print $2}' )
51
+ echo " Defaulting KUBERNETES_VERSION_LATEST_CI to ${KUBERNETES_VERSION_LATEST_CI} to trigger image build (because env var is not set)"
52
+ fi
53
+ elif [[ ${GINKGO_FOCUS:- } != * " K8s-Upgrade" * ]]; then
54
+ # In any other case which is not [K8s-Upgrade], default KUBERNETES_VERSION if it is not set to make sure
55
+ # the corresponding kindest/node image exists.
56
+ if [[ -z " ${KUBERNETES_VERSION:- } " ]]; then
57
+ KUBERNETES_VERSION=$( grep KUBERNETES_VERSION: < " $E2E_CONF_FILE " | awk -F' "' ' { print $2}' )
58
+ echo " Defaulting KUBERNETES_VERSION to ${KUBERNETES_VERSION} to trigger image build (because env var is not set)"
59
+ fi
60
+
61
+ # Tests not focusing on [PR-Blocking] or [K8s-Install], also run upgrade tests so default
62
+ # KUBERNETES_VERSION_UPGRADE_TO to the value in the e2e config if it is not set.
63
+ if [[ ${GINKGO_FOCUS:- } != * " PR-Blocking" * ]] && [[ ${GINKGO_FOCUS:- } != * " K8s-Install" * ]]; then
64
+ if [[ -z " ${KUBERNETES_VERSION_UPGRADE_TO:- } " ]]; then
65
+ KUBERNETES_VERSION_UPGRADE_TO=$( grep KUBERNETES_VERSION_UPGRADE_TO: < " $E2E_CONF_FILE " | awk -F' "' ' { print $2}' )
66
+ echo " Defaulting KUBERNETES_VERSION_UPGRADE_TO to ${KUBERNETES_VERSION_UPGRADE_TO} to trigger image build (because env var is not set)"
67
+ fi
68
+ fi
69
+ fi
70
+ }
71
+
37
72
# k8s::prepareKindestImages checks all the e2e test variables representing a Kubernetes version,
38
73
# and makes sure a corresponding kindest/node image is available locally.
39
74
k8s::prepareKindestImages () {
@@ -65,15 +100,6 @@ k8s::prepareKindestImages() {
65
100
kind::prepareKindestImage " $resolveVersion "
66
101
fi
67
102
68
- # If the test focuses on [K8s-Install-ci-latest], default KUBERNETES_VERSION_LATEST_CI
69
- # to the value in the e2e config if it is not set.
70
- # Note: We do this because we want to specify KUBERNETES_VERSION_LATEST_CI *only* in the e2e config.
71
- if [[ ${GINKGO_FOCUS:- } == * " K8s-Install-ci-latest" * ]]; then
72
- if [[ -z " ${KUBERNETES_VERSION_LATEST_CI:- } " ]]; then
73
- KUBERNETES_VERSION_LATEST_CI=$( grep KUBERNETES_VERSION_LATEST_CI < " $E2E_CONF_FILE " | awk -F' "' ' { print $2}' )
74
- echo " Defaulting KUBERNETES_VERSION_LATEST_CI to ${KUBERNETES_VERSION_LATEST_CI} to trigger image build (because env var is not set)"
75
- fi
76
- fi
77
103
if [ -n " ${KUBERNETES_VERSION_LATEST_CI:- } " ]; then
78
104
k8s::resolveVersion " KUBERNETES_VERSION_LATEST_CI" " $KUBERNETES_VERSION_LATEST_CI "
79
105
export KUBERNETES_VERSION_LATEST_CI=$resolveVersion
0 commit comments