@@ -32,6 +32,20 @@ export IMAGE_TAG
32
32
OPCON_IMG := $(OPCON_IMAGE_REPO ) :$(IMAGE_TAG )
33
33
CATD_IMG := $(CATD_IMAGE_REPO ) :$(IMAGE_TAG )
34
34
35
+ # Extract Kubernetes client-go version used to set the version to the PSA labels, for ENVTEST and KIND
36
+ ifeq ($(origin K8S_VERSION ) , undefined)
37
+ K8S_VERSION := $(shell go list -m k8s.io/client-go | cut -d" " -f2 | sed -E 's/^v0\.([0-9]+) \.[0-9]+$$/1.\1/')
38
+ endif
39
+
40
+ # Ensure ENVTEST_VERSION follows correct "X.Y.x" format
41
+ ENVTEST_VERSION := $(K8S_VERSION ) .x
42
+
43
+ # Not guaranteed to have patch releases available and node image tags are full versions (i.e v1.28.0 - no v1.28, v1.29, etc.)
44
+ # The K8S_VERSION is set by getting the version of the k8s.io/client-go dependency from the go.mod
45
+ # and sets major version to "1" and the patch version to "0". For example, a client-go version of v0.28.5
46
+ # will map to a K8S_VERSION of 1.28.0
47
+ KIND_CLUSTER_IMAGE := kindest/node:v$(K8S_VERSION ) .0
48
+
35
49
# Define dependency versions (use go.mod if we also use Go code from dependency)
36
50
export CERT_MGR_VERSION := v1.15.3
37
51
export WAIT_TIMEOUT := 60s
@@ -54,12 +68,6 @@ ifeq ($(origin KIND_CLUSTER_NAME), undefined)
54
68
KIND_CLUSTER_NAME := operator-controller
55
69
endif
56
70
57
- # Not guaranteed to have patch releases available and node image tags are full versions (i.e v1.28.0 - no v1.28, v1.29, etc.)
58
- # The KIND_NODE_VERSION is set by getting the version of the k8s.io/client-go dependency from the go.mod
59
- # and sets major version to "1" and the patch version to "0". For example, a client-go version of v0.28.5
60
- # will map to a KIND_NODE_VERSION of 1.28.0
61
- KIND_NODE_VERSION := $(shell go list -m k8s.io/client-go | cut -d" " -f2 | sed 's/^v0\.\([[:digit:]]\{1,\}\) \.[[:digit:]]\{1,\}$$/1.\1.0/')
62
- KIND_CLUSTER_IMAGE := kindest/node:v$(KIND_NODE_VERSION )
63
71
64
72
ifneq (, $(shell command -v docker 2>/dev/null) )
65
73
CONTAINER_RUNTIME := docker
@@ -143,9 +151,15 @@ generate: $(CONTROLLER_GEN) #EXHELP Generate code containing DeepCopy, DeepCopyI
143
151
$(CONTROLLER_GEN ) object:headerFile=" hack/boilerplate.go.txt" paths=" ./..."
144
152
145
153
.PHONY : verify
146
- verify : tidy fmt generate manifests crd-ref-docs # HELP Verify all generated code is up-to-date.
154
+ verify : tidy fmt generate manifests crd-ref-docs update-k8s-values # HELP Verify all generated code is up-to-date.
147
155
git diff --exit-code
148
156
157
+ .PHONY : update-k8s-values # HELP Update PSA labels in config manifests with Kubernetes version
158
+ update-k8s-values :
159
+ find config -type f -name ' *.yaml' -exec \
160
+ sed -i.bak -E ' s/(pod-security.kubernetes.io\/[a-zA-Z-]+-version:).*/\1 "v$(K8S_VERSION)"/g' {} +;
161
+ find config -type f -name ' *.yaml.bak' -delete
162
+
149
163
.PHONY : fix-lint
150
164
fix-lint : $(GOLANGCI_LINT ) # EXHELP Fix lint issues
151
165
$(GOLANGCI_LINT ) run --fix --build-tags $(GO_BUILD_TAGS ) $(GOLANGCI_LINT_ARGS )
@@ -194,7 +208,6 @@ test-ext-dev-e2e: $(OPERATOR_SDK) $(KUSTOMIZE) $(KIND) #HELP Run extension creat
194
208
test/extension-developer-e2e/setup.sh $(OPERATOR_SDK ) $(CONTAINER_RUNTIME ) $(KUSTOMIZE ) $(KIND ) $(KIND_CLUSTER_NAME ) $(E2E_REGISTRY_NAMESPACE )
195
209
go test -count=1 -v ./test/extension-developer-e2e/...
196
210
197
- ENVTEST_VERSION := $(shell go list -m k8s.io/client-go | cut -d" " -f2 | sed 's/^v0\.\([[:digit:]]\{1,\}\) \.[[:digit:]]\{1,\}$$/1.\1.x/')
198
211
UNIT_TEST_DIRS := $(shell go list ./... | grep -v /test/)
199
212
COVERAGE_UNIT_DIR := $(ROOT_DIR ) /coverage/unit
200
213
0 commit comments