4646GOBIN =$(shell go env GOBIN)
4747endif
4848
49- OPERATOR_SDK_VERSION ?= v1.38 .0
49+ OPERATOR_SDK_VERSION ?= v1.40 .0
5050OLM_VERSION ?= v0.18.3
51- OPM_VERSION ?= v1.23 .2
52- KUSTOMIZE_VERSION ?= v5.5 .0
51+ OPM_VERSION ?= v1.55 .2
52+ KUSTOMIZE_VERSION ?= v5.6 .0
5353KUSTOMIZE =$(shell pwd) /_cache/kustomize
54- KIND ?= $(shell pwd) /_cache/kind
55- KIND_VERSION =v0.23.0
54+ KIND_VERSION ?= v0.29.0
55+ KUBECTL_VERSION ?= v1.33.1
56+ ENVTEST_VERSION ?= 1.33.0
57+ CONTROLLER_GEN_VERSION ?= v0.18.0
5658CACHE_PATH =$(shell pwd) /_cache
5759
5860
@@ -62,11 +64,9 @@ OPM_TOOL_URL=https://api.github.com/repos/operator-framework/operator-registry/r
6264TESTS_REPORTS_PATH ?= /tmp/test_e2e_logs/
6365VALIDATION_TESTS_REPORTS_PATH ?= /tmp/test_validation_logs/
6466
65- ENVTEST_ASSETS_DIR =$(shell pwd) /testbin
66- test : generate fmt vet manifests # # Run unit and integration tests
67- mkdir -p ${ENVTEST_ASSETS_DIR}
68- test -f ${ENVTEST_ASSETS_DIR} /setup-envtest.sh || curl -sSLo ${ENVTEST_ASSETS_DIR} /setup-envtest.sh https://raw.githubusercontent.com/kubernetes-sigs/controller-runtime/v0.8.3/hack/setup-envtest.sh
69- source ${ENVTEST_ASSETS_DIR} /setup-envtest.sh; fetch_envtest_tools $(ENVTEST_ASSETS_DIR ) ; setup_envtest_env $(ENVTEST_ASSETS_DIR ) ; go test -race ./... -coverprofile cover.out
67+ test : generate fmt vet manifests setup-envtest # # Run unit and integration tests
68+ source <( _cache/setup-envtest use -p env --bin-dir ${CACHE_PATH} ${ENVTEST_VERSION} ) && \
69+ go test -race ./... -coverprofile cover.out
7070
7171all : manager # # Default make target if no options specified
7272
@@ -126,7 +126,7 @@ bin: manifests kustomize ## Create manifests
126126 $(KUSTOMIZE ) build config/metallb_rbac >> bin/$(BIN_FILE )
127127
128128manifests : controller-gen generate-metallb-manifests # # Generate manifests e.g. CRD, RBAC etc.
129- $(CONTROLLER_GEN ) $(CRD_OPTIONS ) rbac:roleName=metallb-manager-role webhook paths=" ./..." output:crd:artifacts:config=config/crd/bases
129+ $(CACHE_PATH ) /controller-gen $(CRD_OPTIONS ) rbac:roleName=metallb-manager-role webhook paths=" ./..." output:crd:artifacts:config=config/crd/bases
130130 sed -i -e ' s/validating-webhook-configuration/metallb-operator-webhook-configuration/g' config/webhook/manifests.yaml
131131 sed -i -e ' s/webhook-service/metallb-operator-webhook-service/g' config/webhook/manifests.yaml
132132
@@ -138,7 +138,7 @@ vet: ## Run go vet against code
138138 go vet ./...
139139
140140generate : controller-gen # # Generate code
141- $(CONTROLLER_GEN ) object:headerFile=" hack/boilerplate.go.txt" paths=" ./..."
141+ $(CACHE_PATH ) /controller-gen object:headerFile=" hack/boilerplate.go.txt" paths=" ./..."
142142
143143# Build the docker image
144144docker-build : # # Build the docker image
@@ -162,11 +162,11 @@ build-bundle: ## Build the bundle image.
162162
163163.PHONY : kind-cluster
164164kind-cluster : kind
165- KIND_BIN=$(KIND ) hack/kind/kind.sh
165+ KIND_BIN=$(CACHE_PATH ) /kind hack/kind/kind.sh
166166
167167.PHONY : load-on-kind
168168load-on-kind : docker-build kind-cluster # # Load the docker image into the kind cluster.
169- $(KIND ) load docker-image ${IMG}
169+ $(CACHE_PATH ) /kind load docker-image ${IMG}
170170
171171deploy-olm : export KIND_WITH_REGISTRY=true
172172deploy-olm : operator-sdk kind-cluster # # deploys OLM on the cluster
@@ -194,16 +194,19 @@ build-and-push-bundle-images: docker-build docker-push ## Generate and push bun
194194deploy-prometheus :
195195 hack/deploy_prometheus.sh
196196
197- # find or download controller-gen
198- # download controller-gen if necessary
197+ setup-envtest :
198+ mkdir -p _cache
199+ ifeq (,$(findstring v0.0.0,$(shell _cache/setup-envtest version) ) )
200+ GOBIN=$(CACHE_PATH) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
201+ endif
202+
199203controller-gen :
200- ifeq (, $(shell which controller-gen) )
201- go install sigs.k8s.io/controller-tools/cmd/
[email protected] 202- CONTROLLER_GEN =$(GOBIN ) /controller-gen
203- else
204- CONTROLLER_GEN =$(shell which controller-gen)
204+ mkdir -p _cache
205+ ifeq (,$(findstring $(CONTROLLER_GEN_VERSION ) ,$(shell _cache/controller-gen --version) ) )
206+ GOBIN=$(CACHE_PATH) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_GEN_VERSION)
205207endif
206208
209+
207210# Get the current operator-sdk binary into the _cache dir.
208211kustomize :
209212 mkdir -p _cache
@@ -246,7 +249,7 @@ kubectl:
246249ifeq (, $(shell which kubectl) )
247250 @{ \
248251 set -e ;\
249- curl -LO https://dl.k8s.io/release/v1.23.0 /bin/linux/amd64/kubectl > $(GOBIN)/kubectl ;\
252+ curl -LO https://dl.k8s.io/release/$(KUBECTL_VERSION) /bin/linux/amd64/kubectl > $(GOBIN)/kubectl ;\
250253 chmod u+x $(GOBIN)/kubectl ;\
251254 }
252255endif
0 commit comments