Skip to content

Commit 81b7dc3

Browse files
author
Per Goncalves da Silva
committed
update makefile
Signed-off-by: Per Goncalves da Silva <[email protected]>
1 parent e0fc987 commit 81b7dc3

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

Makefile

+11-13
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,16 @@ else
3939
ARCH := amd64
4040
endif
4141

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
4251
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/')
4852
KIND_CLUSTER_IMAGE := kindest/node:v$(KIND_NODE_VERSION)
4953

5054
# 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)
5559
.PHONY: FORCE
5660
FORCE:
5761

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-
6462
.PHONY: vet
6563
vet:
6664
go vet $(MOD_FLAGS) ./...
@@ -69,8 +67,8 @@ all: test build
6967

7068
test: clean cover.out
7169
.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:
7472
@echo "Running unit tests with kubebuilder assets at $(KUBEBUILDER_ASSETS)"
7573
@echo "Running kube version: $(shell ${KUBEBUILDER_ASSETS}/kubectl version)"
7674
KUBEBUILDER_ASSETS=$(KUBEBUILDER_ASSETS) go test $(MOD_FLAGS) $(SPECIFIC_UNIT_TEST) -tags "json1" -race -count=1 ./pkg/... ./test/e2e/split/...

0 commit comments

Comments
 (0)