@@ -46,8 +46,9 @@ manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and Cust
4646 $(CONTROLLER_GEN ) rbac:roleName=manager-role crd webhook paths=" ./..." output:crd:artifacts:config=config/crd/bases
4747
4848.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.
5050 $(CONTROLLER_GEN ) object paths=" ./..."
51+ go generate ./...
5152
5253.PHONY : fmt
5354fmt : # # Run go fmt against code.
@@ -59,7 +60,7 @@ vet: ## Run go vet against code.
5960
6061.PHONY : test
6162test : 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
6364
6465# TODO(user): To use a different vendor for e2e tests, modify the setup under 'tests/e2e'.
6566# The default setup assumes Kind is pre-installed and builds/loads the Manager Docker image locally.
@@ -191,6 +192,7 @@ CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
191192ENVTEST ?= $(LOCALBIN ) /setup-envtest
192193GOLANGCI_LINT = $(LOCALBIN ) /golangci-lint
193194NILAWAY = $(LOCALBIN ) /nilaway
195+ MOCKGEN = $(LOCALBIN ) /mockgen
194196
195197# # Tool Versions
196198KUSTOMIZE_VERSION ?= v5.6.0
@@ -201,6 +203,7 @@ ENVTEST_VERSION ?= $(shell go list -m -f "{{ .Version }}" sigs.k8s.io/controller
201203ENVTEST_K8S_VERSION ?= $(shell go list -m -f "{{ .Version }}" k8s.io/api | awk -F'[v.]' '{printf "1.% d", $$3}')
202204GOLANGCI_LINT_VERSION ?= v2.1.0
203205NILAWAY_VERSION ?= latest
206+ MOCKGEN_VERSION ?= v0.5.2
204207
205208.PHONY : kustomize
206209kustomize : $(KUSTOMIZE ) # # Download kustomize locally if necessary.
@@ -235,6 +238,11 @@ nilaway: $(NILAWAY) ## Download nilaway locally if necessary.
235238$(NILAWAY ) : $(LOCALBIN )
236239 $(call go-install-tool,$(NILAWAY ) ,go.uber.org/nilaway/cmd/nilaway,$(NILAWAY_VERSION ) )
237240
241+ .PHONY : mockgen
242+ mockgen : $(MOCKGEN ) # # Download mockgen locally if necessary.
243+ $(MOCKGEN ) : $(LOCALBIN )
244+ $(call go-install-tool,$(MOCKGEN ) ,go.uber.org/mock/mockgen,$(MOCKGEN_VERSION ) )
245+
238246# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
239247# $1 - target path with name of binary
240248# $2 - package url which can be installed
0 commit comments