Skip to content

Commit 83f3a8f

Browse files
committed
CI: default building kind node-images depending on KIND_BUILD_IMAGES env variable instead of ginkgo magic regexes
1 parent de183c8 commit 83f3a8f

File tree

1 file changed

+18
-35
lines changed

1 file changed

+18
-35
lines changed

scripts/ci-e2e-lib.sh

Lines changed: 18 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -40,51 +40,34 @@ capi:buildDockerImages () {
4040
# Note: We do this to ensure that the kindest/node image gets built if it does
4141
# not already exist, e.g. for pre-releases, but only if necessary.
4242
k8s::prepareKindestImagesVariables() {
43+
KIND_BUILD_IMAGES="${KIND_BUILD_IMAGES:-}"
44+
4345
# Always default KUBERNETES_VERSION_MANAGEMENT because we always create a management cluster out of it.
4446
if [[ -z "${KUBERNETES_VERSION_MANAGEMENT:-}" ]]; then
4547
KUBERNETES_VERSION_MANAGEMENT=$(grep KUBERNETES_VERSION_MANAGEMENT: < "$E2E_CONF_FILE" | awk -F'"' '{ print $2}')
4648
echo "Defaulting KUBERNETES_VERSION_MANAGEMENT to ${KUBERNETES_VERSION_MANAGEMENT} to trigger image build (because env var is not set)"
4749
fi
4850

49-
if [[ ${GINKGO_FOCUS:-} == *"K8s-Install-ci-latest"* ]]; then
50-
# If the test focuses on [K8s-Install-ci-latest], only default KUBERNETES_VERSION_LATEST_CI
51-
# to the value in the e2e config and only if it is not set.
52-
# Note: We do this because we want to specify KUBERNETES_VERSION_LATEST_CI *only* in the e2e config.
53-
if [[ -z "${KUBERNETES_VERSION_LATEST_CI:-}" ]]; then
54-
KUBERNETES_VERSION_LATEST_CI=$(grep KUBERNETES_VERSION_LATEST_CI: < "$E2E_CONF_FILE" | awk -F'"' '{ print $2}')
55-
echo "Defaulting KUBERNETES_VERSION_LATEST_CI to ${KUBERNETES_VERSION_LATEST_CI} to trigger image build (because env var is not set)"
56-
fi
57-
elif [[ ${GINKGO_FOCUS:-} != *"K8s-Upgrade"* ]]; then
58-
# In any other case which is not [K8s-Upgrade], default KUBERNETES_VERSION if it is not set to make sure
59-
# the corresponding kindest/node image exists.
60-
if [[ -z "${KUBERNETES_VERSION:-}" ]]; then
61-
KUBERNETES_VERSION=$(grep KUBERNETES_VERSION: < "$E2E_CONF_FILE" | awk -F'"' '{ print $2}')
62-
echo "Defaulting KUBERNETES_VERSION to ${KUBERNETES_VERSION} to trigger image build (because env var is not set)"
63-
fi
51+
# Default KUBERNETES_VERSION, KUBERNETES_VERSION_LATEST_CI, KUBERNETES_VERSION_UPGRADE_TO or KUBERNETES_VERSION_UPGRADE_FROM if set in KIND_BUILD_IMAGES var.
52+
53+
if [[ ",${KIND_BUILD_IMAGES}," == *",KUBERNETES_VERSION,"* ]] && [[ -z "${KUBERNETES_VERSION:-}" ]]; then
54+
KUBERNETES_VERSION=$(grep KUBERNETES_VERSION: < "$E2E_CONF_FILE" | awk -F'"' '{ print $2}')
55+
echo "Defaulting KUBERNETES_VERSION to ${KUBERNETES_VERSION} to trigger image build (because env var is not set)"
6456
fi
6557

66-
# Tests not focusing on anything and skipping [Conformance] run a clusterctl upgrade test
67-
# on the latest kubernetes version as management cluster.
68-
if [[ ${GINKGO_FOCUS:-} == "" ]] && [[ ${GINKGO_SKIP} == *"Conformance"* ]]; then
69-
# Note: We do this because we want to specify KUBERNETES_VERSION_LATEST_CI *only* in the e2e config.
70-
if [[ -z "${KUBERNETES_VERSION_LATEST_CI:-}" ]]; then
71-
KUBERNETES_VERSION_LATEST_CI=$(grep KUBERNETES_VERSION_LATEST_CI: < "$E2E_CONF_FILE" | awk -F'"' '{ print $2}')
72-
echo "Defaulting KUBERNETES_VERSION_LATEST_CI to ${KUBERNETES_VERSION_LATEST_CI} to trigger image build (because env var is not set)"
73-
fi
58+
if [[ ",${KIND_BUILD_IMAGES}," == *",KUBERNETES_VERSION_LATEST_CI,"* ]] && [[ -z "${KUBERNETES_VERSION_LATEST_CI:-}" ]]; then
59+
KUBERNETES_VERSION_LATEST_CI=$(grep KUBERNETES_VERSION_LATEST_CI: < "$E2E_CONF_FILE" | awk -F'"' '{ print $2}')
60+
echo "Defaulting KUBERNETES_VERSION_LATEST_CI to ${KUBERNETES_VERSION_LATEST_CI} to trigger image build (because env var is not set)"
7461
fi
7562

76-
# Tests not focusing on [PR-Blocking], [K8s-Install] or [K8s-Install-ci-latest],
77-
# also run upgrade tests so default KUBERNETES_VERSION_UPGRADE_TO and KUBERNETES_VERSION_UPGRADE_FROM
78-
# to the value in the e2e config if they are not set.
79-
if [[ ${GINKGO_FOCUS:-} != *"PR-Blocking"* ]] && [[ ${GINKGO_FOCUS:-} != *"K8s-Install"* ]]; then
80-
if [[ -z "${KUBERNETES_VERSION_UPGRADE_TO:-}" ]]; then
81-
KUBERNETES_VERSION_UPGRADE_TO=$(grep KUBERNETES_VERSION_UPGRADE_TO: < "$E2E_CONF_FILE" | awk -F'"' '{ print $2}')
82-
echo "Defaulting KUBERNETES_VERSION_UPGRADE_TO to ${KUBERNETES_VERSION_UPGRADE_TO} to trigger image build (because env var is not set)"
83-
fi
84-
if [[ -z "${KUBERNETES_VERSION_UPGRADE_FROM:-}" ]]; then
85-
KUBERNETES_VERSION_UPGRADE_FROM=$(grep KUBERNETES_VERSION_UPGRADE_FROM: < "$E2E_CONF_FILE" | awk -F'"' '{ print $2}')
86-
echo "Defaulting KUBERNETES_VERSION_UPGRADE_FROM to ${KUBERNETES_VERSION_UPGRADE_FROM} to trigger image build (because env var is not set)"
87-
fi
63+
if [[ ",${KIND_BUILD_IMAGES}," == *",KUBERNETES_VERSION_UPGRADE_TO,"* ]] && [[ -z "${KUBERNETES_VERSION_UPGRADE_TO:-}" ]]; then
64+
KUBERNETES_VERSION_UPGRADE_TO=$(grep KUBERNETES_VERSION_UPGRADE_TO: < "$E2E_CONF_FILE" | awk -F'"' '{ print $2}')
65+
echo "Defaulting KUBERNETES_VERSION_UPGRADE_TO to ${KUBERNETES_VERSION_UPGRADE_TO} to trigger image build (because env var is not set)"
66+
fi
67+
68+
if [[ ",${KIND_BUILD_IMAGES}," == *",KUBERNETES_VERSION_UPGRADE_FROM,"* ]] && [[ -z "${KUBERNETES_VERSION_UPGRADE_FROM:-}" ]]; then
69+
KUBERNETES_VERSION_UPGRADE_FROM=$(grep KUBERNETES_VERSION_UPGRADE_FROM: < "$E2E_CONF_FILE" | awk -F'"' '{ print $2}')
70+
echo "Defaulting KUBERNETES_VERSION_UPGRADE_FROM to ${KUBERNETES_VERSION_UPGRADE_FROM} to trigger image build (because env var is not set)"
8871
fi
8972
}
9073

0 commit comments

Comments
 (0)