@@ -46,8 +46,9 @@ manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and Cust
46
46
$(CONTROLLER_GEN ) rbac:roleName=manager-role crd webhook paths=" ./..." output:crd:artifacts:config=config/crd/bases
47
47
48
48
.PHONY : generate
49
- generate : controller-gen # # Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
49
+ generate : controller-gen mockgen # # Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
50
50
$(CONTROLLER_GEN ) object paths=" ./..."
51
+ go generate ./...
51
52
52
53
.PHONY : fmt
53
54
fmt : # # Run go fmt against code.
@@ -59,7 +60,7 @@ vet: ## Run go vet against code.
59
60
60
61
.PHONY : test
61
62
test : manifests generate fmt vet setup-envtest # # Run tests.
62
- KUBEBUILDER_ASSETS=" $( shell $( ENVTEST) use $( ENVTEST_K8S_VERSION) --bin-dir $( LOCALBIN) -p path) " go test $$(go list ./... | grep -v /e2e ) -coverprofile cover.out
63
+ KUBEBUILDER_ASSETS=" $( shell $( ENVTEST) use $( ENVTEST_K8S_VERSION) --bin-dir $( LOCALBIN) -p path) " go test $$(go list ./... | grep -v /e2e | grep -v /mock ) -coverprofile cover.out
63
64
64
65
# TODO(user): To use a different vendor for e2e tests, modify the setup under 'tests/e2e'.
65
66
# The default setup assumes Kind is pre-installed and builds/loads the Manager Docker image locally.
@@ -189,6 +190,7 @@ KUSTOMIZE ?= $(LOCALBIN)/kustomize
189
190
CONTROLLER_GEN ?= $(LOCALBIN ) /controller-gen
190
191
ENVTEST ?= $(LOCALBIN ) /setup-envtest
191
192
GOLANGCI_LINT = $(LOCALBIN ) /golangci-lint
193
+ MOCKGEN = $(LOCALBIN ) /mockgen
192
194
193
195
# # Tool Versions
194
196
KUSTOMIZE_VERSION ?= v5.6.0
@@ -198,6 +200,7 @@ ENVTEST_VERSION ?= $(shell go list -m -f "{{ .Version }}" sigs.k8s.io/controller
198
200
# ENVTEST_K8S_VERSION is the version of Kubernetes to use for setting up ENVTEST binaries (i.e. 1.31)
199
201
ENVTEST_K8S_VERSION ?= $(shell go list -m -f "{{ .Version }}" k8s.io/api | awk -F'[v.]' '{printf "1.% d", $$3}')
200
202
GOLANGCI_LINT_VERSION ?= v2.1.0
203
+ MOCKGEN_VERSION ?= v0.5.2
201
204
202
205
.PHONY : kustomize
203
206
kustomize : $(KUSTOMIZE ) # # Download kustomize locally if necessary.
@@ -227,6 +230,11 @@ golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
227
230
$(GOLANGCI_LINT ) : $(LOCALBIN )
228
231
$(call go-install-tool,$(GOLANGCI_LINT ) ,github.com/golangci/golangci-lint/v2/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION ) )
229
232
233
+ .PHONY : mockgen
234
+ mockgen : $(MOCKGEN ) # # Download mockgen locally if necessary.
235
+ $(MOCKGEN ) : $(LOCALBIN )
236
+ $(call go-install-tool,$(MOCKGEN ) ,go.uber.org/mock/mockgen,$(MOCKGEN_VERSION ) )
237
+
230
238
# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
231
239
# $1 - target path with name of binary
232
240
# $2 - package url which can be installed
0 commit comments