Skip to content

Commit 03eb884

Browse files
authored
Use local cache to check kind version (#2346)
Use the local cached source of kind to determine the k8s version it supports. It avoids hitting github if possible. Signed-off-by: Todd Short <[email protected]>
1 parent f3569d5 commit 03eb884

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ kind-clean: $(KIND) #EXHELP Delete the kind cluster.
386386
$(KIND) delete cluster --name $(KIND_CLUSTER_NAME)
387387

388388
.PHONY: kind-verify-versions
389-
kind-verify-versions:
389+
kind-verify-versions: $(KIND)
390390
env K8S_VERSION=v$(K8S_VERSION) KIND=$(KIND) GOBIN=$(GOBIN) hack/tools/validate_kindest_node.sh
391391

392392

hack/tools/validate_kindest_node.sh

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,24 @@
44
# Extract the version of kind, by removing the "${GOBIN}/kind-" prefix
55
KIND=${KIND#${GOBIN}/kind-}
66

7-
# Get the version of the image
8-
KIND_VER=$(curl -L -s https://github.com/kubernetes-sigs/kind/raw/refs/tags/${KIND}/pkg/apis/config/defaults/image.go | grep -Eo 'v[0-9]+\.[0-9]+')
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)
14+
fi
15+
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
20+
21+
if [ -z "${KIND_VER}" ]; then
22+
echo "Unable to determine kindest/node version"
23+
exit 1
24+
fi
925

1026
# Compare the versions
1127
if [ "${KIND_VER}" != "${K8S_VERSION}" ]; then

0 commit comments

Comments
 (0)