|
1 | 1 | #!/bin/bash |
2 | | -# This script verifies that the version of kind used for testing uses a major.minor version of k8s that operator-controller does |
| 2 | +set -euo pipefail |
| 3 | +# Outputs the kindest/node image for the given K8S_VERSION. |
| 4 | +# The KIND_IMAGES block below is regenerated by `make kind-update-images`. |
3 | 5 |
|
4 | | -# Extract the version of kind, by removing the "${GOBIN}/kind-" prefix |
5 | | -KIND=${KIND#${GOBIN}/kind-} |
6 | | - |
7 | | -GOMODCACHE=$(go env GOMODCACHE) |
8 | | - |
9 | | -REGEX='v[0-9]+\.[0-9]+' |
10 | | - |
11 | | -# Get the version of the image from the local kind build |
12 | | -if [ -d "${GOMODCACHE}" ]; then |
13 | | - KIND_VER=$(grep -Eo "${REGEX}" ${GOMODCACHE}/sigs.k8s.io/kind@${KIND}/pkg/apis/config/defaults/image.go) |
| 6 | +if [ -z "${K8S_VERSION:-}" ]; then |
| 7 | + echo "Error: K8S_VERSION is not set." >&2 |
| 8 | + exit 1 |
14 | 9 | fi |
15 | 10 |
|
16 | | -# Get the version of the image from github |
17 | | -if [ -z "${KIND_VER}" ]; then |
18 | | - KIND_VER=$(curl -L -s https://github.com/kubernetes-sigs/kind/raw/refs/tags/${KIND}/pkg/apis/config/defaults/image.go | grep -Eo "${REGEX}") |
19 | | -fi |
| 11 | +K8S_MINOR=$(echo "${K8S_VERSION}" | sed -E 's/^v?([0-9]+\.[0-9]+).*/\1/') |
20 | 12 |
|
21 | | -if [ -z "${KIND_VER}" ]; then |
22 | | - echo "Unable to determine kindest/node version" |
23 | | - exit 1 |
24 | | -fi |
| 13 | +# --- BEGIN KIND IMAGES --- |
| 14 | +# kind v0.32.0 |
| 15 | +case "${K8S_MINOR}" in |
| 16 | + 1.33) IMAGE="kindest/node:v1.33.12" ;; |
| 17 | + 1.34) IMAGE="kindest/node:v1.34.8" ;; |
| 18 | + 1.35) IMAGE="kindest/node:v1.35.5" ;; |
| 19 | + 1.36) IMAGE="kindest/node:v1.36.1" ;; |
| 20 | + *) IMAGE="" ;; |
| 21 | +esac |
| 22 | +# --- END KIND IMAGES --- |
25 | 23 |
|
26 | | -# Compare the versions |
27 | | -if [ "${KIND_VER}" != "${K8S_VERSION}" ]; then |
28 | | - echo "kindest/node:${KIND_VER} version does not match k8s ${K8S_VERSION}" |
| 24 | +if [ -z "${IMAGE}" ]; then |
| 25 | + echo "Error: no kindest/node image for k8s ${K8S_MINOR}." >&2 |
| 26 | + echo "Run 'make kind-update-images' after bumping kind." >&2 |
29 | 27 | exit 1 |
30 | 28 | fi |
31 | | -exit 0 |
| 29 | +echo "${IMAGE}" |
0 commit comments