39
39
ARCH := amd64
40
40
endif
41
41
42
+ # Track the minor version of kubernetes we are building against by looking at the client-go dependency version
43
+ # For example, a client-go version of v0.28.5 will map to kube version 1.28
44
+ KUBE_MINOR ?= $(shell go list -m k8s.io/client-go | cut -d" " -f2 | sed 's/^v0\.\([[:digit:]]\{1,\}\) \.[[:digit:]]\{1,\}$$/1.\1/')
45
+
46
+ # Unit test against the latest available version for the minor version of kubernetes we are building against e.g. 1.30.x
47
+ ENVTEST_KUBE_VERSION ?= $(KUBE_MINOR ) .x
48
+
49
+ # Not guaranteed to have patch releases available and node image tags are full versions (i.e v1.28.0 - not v1.28, v1.29, etc.)
50
+ KIND_NODE_VERSION ?= $(KUBE_MINOR ) .0
42
51
KIND_CLUSTER_NAME ?= kind-olmv0
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 KIND_NODE_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 KIND_NODE_VERSION of 1.28.0
47
- KIND_NODE_VERSION := $(shell go list -m k8s.io/client-go | cut -d" " -f2 | sed 's/^v0\.\([[:digit:]]\{1,\}\) \.[[:digit:]]\{1,\}$$/1.\1.0/')
48
52
KIND_CLUSTER_IMAGE := kindest/node:v$(KIND_NODE_VERSION )
49
53
50
54
# Phony prerequisite for targets that rely on the go build cache to determine staleness.
@@ -55,12 +59,6 @@ KIND_CLUSTER_IMAGE := kindest/node:v$(KIND_NODE_VERSION)
55
59
.PHONY : FORCE
56
60
FORCE :
57
61
58
- .PHONY : setup-envtest
59
- setup-envtest :
60
- ifeq (, $(shell which setup-envtest) )
61
- go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
62
- endif
63
-
64
62
.PHONY : vet
65
63
vet :
66
64
go vet $(MOD_FLAGS ) ./...
@@ -69,8 +67,8 @@ all: test build
69
67
70
68
test : clean cover.out
71
69
.PHONY : unit
72
- KUBEBUILDER_ASSETS ?= $(shell setup-envtest use -p path $(KIND_NODE_VERSION ) )
73
- unit : setup-envtest
70
+ KUBEBUILDER_ASSETS ?= $(shell $( SETUP_ENVTEST ) use -p path $(ENVTEST_KUBE_VERSION ) )
71
+ unit :
74
72
@echo " Running unit tests with kubebuilder assets at $( KUBEBUILDER_ASSETS) "
75
73
@echo " Running kube version: $( shell ${KUBEBUILDER_ASSETS} /kubectl version) "
76
74
KUBEBUILDER_ASSETS=$(KUBEBUILDER_ASSETS ) go test $(MOD_FLAGS ) $(SPECIFIC_UNIT_TEST ) -tags " json1" -race -count=1 ./pkg/... ./test/e2e/split/...
0 commit comments