@@ -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 defaulter-gen # # Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
5050 $(CONTROLLER_GEN ) object:headerFile=" hack/boilerplate.go.txt" paths=" ./..."
51+ $(DEFAULTER_GEN ) ./internal/config --output-file=zz_generated.defaults.go
5152
5253.PHONY : fmt
5354fmt : # # Run go fmt against code.
@@ -168,17 +169,19 @@ KUBECTL ?= kubectl
168169KIND ?= kind
169170KUSTOMIZE ?= $(LOCALBIN ) /kustomize
170171CONTROLLER_GEN ?= $(LOCALBIN ) /controller-gen
172+ DEFAULTER_GEN ?= $(LOCALBIN ) /defaulter-gen
171173ENVTEST ?= $(LOCALBIN ) /setup-envtest
172174GOLANGCI_LINT = $(LOCALBIN ) /golangci-lint
173175
174176# # Tool Versions
175177KUSTOMIZE_VERSION ?= v5.6.0
176178CONTROLLER_TOOLS_VERSION ?= v0.17.2
179+ DEFAULTER_GEN_VERSION ?= v0.32.3
177180# ENVTEST_VERSION is the version of controller-runtime release branch to fetch the envtest setup script (i.e. release-0.20)
178181ENVTEST_VERSION ?= $(shell go list -m -f "{{ .Version }}" sigs.k8s.io/controller-runtime | awk -F'[v.]' '{printf "release-% d.% d", $$2, $$3}')
179182# ENVTEST_K8S_VERSION is the version of Kubernetes to use for setting up ENVTEST binaries (i.e. 1.31)
180183ENVTEST_K8S_VERSION ?= $(shell go list -m -f "{{ .Version }}" k8s.io/api | awk -F'[v.]' '{printf "1.% d", $$3}')
181- GOLANGCI_LINT_VERSION ?= v1.63.4
184+ GOLANGCI_LINT_VERSION ?= v2.1.6
182185
183186.PHONY : kustomize
184187kustomize : $(KUSTOMIZE ) # # Download kustomize locally if necessary.
@@ -190,6 +193,11 @@ controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessar
190193$(CONTROLLER_GEN ) : $(LOCALBIN )
191194 $(call go-install-tool,$(CONTROLLER_GEN ) ,sigs.k8s.io/controller-tools/cmd/controller-gen,$(CONTROLLER_TOOLS_VERSION ) )
192195
196+ .PHONY : defaulter-gen
197+ defaulter-gen : $(DEFAULTER_GEN ) # # Download defaulter-gen locally if necessary.
198+ $(DEFAULTER_GEN ) : $(LOCALBIN )
199+ $(call go-install-tool,$(DEFAULTER_GEN ) ,k8s.io/code-generator/cmd/defaulter-gen,$(DEFAULTER_GEN_VERSION ) )
200+
193201.PHONY : setup-envtest
194202setup-envtest : envtest # # Download the binaries required for ENVTEST in the local bin directory.
195203 @echo " Setting up envtest binaries for Kubernetes version $( ENVTEST_K8S_VERSION) ..."
@@ -206,7 +214,7 @@ $(ENVTEST): $(LOCALBIN)
206214.PHONY : golangci-lint
207215golangci-lint : $(GOLANGCI_LINT ) # # Download golangci-lint locally if necessary.
208216$(GOLANGCI_LINT ) : $(LOCALBIN )
209- $(call go-install-tool,$(GOLANGCI_LINT ) ,github.com/golangci/golangci-lint/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION ) )
217+ $(call go-install-tool,$(GOLANGCI_LINT ) ,github.com/golangci/golangci-lint/v2/ cmd/golangci-lint,$(GOLANGCI_LINT_VERSION ) )
210218
211219# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
212220# $1 - target path with name of binary
0 commit comments