88GOBIN =$(shell go env GOBIN)
99endif
1010
11+ TOOLS_DIR := hack/tools
1112ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST ) ) ) )
1213
1314# CONTAINER_TOOL defines the container tool to be used for building images.
@@ -48,10 +49,14 @@ manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and Cust
4849 $(CONTROLLER_GEN ) rbac:roleName=manager-role crd webhook paths=" ./..." output:crd:artifacts:config=config/crd/bases
4950
5051.PHONY : generate
51- generate : controller-gen mockgen # # Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
52+ generate : controller-gen generate-go-conversions mockgen # # Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
5253 $(CONTROLLER_GEN ) object paths=" ./..."
5354 go generate ./...
5455
56+ .PHONY : generate-go-conversions
57+ generate-go-conversions : conversion-gen # # Generate conversions go code
58+ $(CONVERSION_GEN ) --output-file=zz_generated.conversion.go github.com/scaleway/cluster-api-provider-scaleway/api/...
59+
5560.PHONY : fmt
5661fmt : # # Run go fmt against code.
5762 go fmt ./...
@@ -70,7 +75,7 @@ KIND_KUBECONFIG ?= /tmp/caps-e2e-kubeconfig
7075E2E_ARTIFACTS ?= $(ROOT_DIR ) /_artifacts
7176E2E_CONF_FILE ?= $(ROOT_DIR ) /test/e2e/config/scaleway.yaml
7277E2E_CONF_FILE_ENVSUBST := $(ROOT_DIR ) /test/e2e/config/scaleway-envsubst.yaml
73- E2E_V1BETA1_TEMPLATES := $(ROOT_DIR ) /test/e2e/data/infrastructure-scaleway/v1beta1
78+ E2E_V1BETA2_TEMPLATES := $(ROOT_DIR ) /test/e2e/data/infrastructure-scaleway/v1beta2
7479E2E_FOCUS ?= ""
7580
7681.PHONY : setup-test-e2e
@@ -83,9 +88,9 @@ setup-test-e2e: ## Set up a Kind cluster for e2e tests if it does not exist
8388
8489.PHONY : generate-e2e
8590generate-e2e : kustomize # # Generate templates for e2e
86- $(KUSTOMIZE ) build $(E2E_V1BETA1_TEMPLATES ) /cluster-template --load-restrictor LoadRestrictionsNone > $(E2E_V1BETA1_TEMPLATES ) /cluster-template.yaml
87- $(KUSTOMIZE ) build $(E2E_V1BETA1_TEMPLATES ) /cluster-template-private-network --load-restrictor LoadRestrictionsNone > $(E2E_V1BETA1_TEMPLATES ) /cluster-template-private-network.yaml
88- $(KUSTOMIZE ) build $(E2E_V1BETA1_TEMPLATES ) /cluster-template-managed --load-restrictor LoadRestrictionsNone > $(E2E_V1BETA1_TEMPLATES ) /cluster-template-managed.yaml
91+ $(KUSTOMIZE ) build $(E2E_V1BETA2_TEMPLATES ) /cluster-template --load-restrictor LoadRestrictionsNone > $(E2E_V1BETA2_TEMPLATES ) /cluster-template.yaml
92+ $(KUSTOMIZE ) build $(E2E_V1BETA2_TEMPLATES ) /cluster-template-private-network --load-restrictor LoadRestrictionsNone > $(E2E_V1BETA2_TEMPLATES ) /cluster-template-private-network.yaml
93+ $(KUSTOMIZE ) build $(E2E_V1BETA2_TEMPLATES ) /cluster-template-managed --load-restrictor LoadRestrictionsNone > $(E2E_V1BETA2_TEMPLATES ) /cluster-template-managed.yaml
8994
9095.PHONY : test-e2e
9196test-e2e : setup-test-e2e generate-e2e docker-build envsubst ginkgo build-installer fmt vet # # Run the e2e tests. Expected an isolated environment using Kind.
@@ -101,13 +106,17 @@ cleanup-test-e2e: ## Tear down the Kind cluster used for e2e tests
101106 @$(KIND ) delete cluster --name $(KIND_CLUSTER ) --kubeconfig $(KIND_KUBECONFIG )
102107
103108.PHONY : lint
104- lint : lint-golangci-lint lint-nilaway # # Run linters
109+ lint : lint-api lint- golangci-lint lint-nilaway # # Run linters
105110 @echo " done"
106111
107112.PHONY : lint-golangci-lint
108113lint-golangci-lint : golangci-lint # # Run golangci-lint linter
109114 $(GOLANGCI_LINT ) run
110115
116+ .PHONY : lint-api
117+ lint-api : golangci-lint-kube-api-linter # # Run golangci-lint-kube-api-linter linter
118+ $(GOLANGCI_LINT_KAL ) run --config .golangci-kal.yml
119+
111120.PHONY : lint-nilaway
112121lint-nilaway : nilaway # # Run nilaway linter
113122 $(NILAWAY ) -include-pkgs=github.com/scaleway/cluster-api-provider-scaleway ./...
@@ -217,19 +226,22 @@ NILAWAY = $(LOCALBIN)/nilaway
217226MOCKGEN = $(LOCALBIN ) /mockgen
218227ENVSUBST = $(LOCALBIN ) /envsubst
219228GINKGO = $(LOCALBIN ) /ginkgo
229+ GOLANGCI_LINT_KAL := $(LOCALBIN ) /golangci-lint-kube-api-linter
230+ CONVERSION_GEN ?= $(LOCALBIN ) /conversion-gen
220231
221232# # Tool Versions
222- KUSTOMIZE_VERSION ?= v5.6.0
223- CONTROLLER_TOOLS_VERSION ?= v0.18 .0
233+ KUSTOMIZE_VERSION ?= v5.7.1
234+ CONTROLLER_TOOLS_VERSION ?= v0.19 .0
224235# ENVTEST_VERSION is the version of controller-runtime release branch to fetch the envtest setup script (i.e. release-0.20)
225236ENVTEST_VERSION ?= $(shell go list -m -f "{{ .Version }}" sigs.k8s.io/controller-runtime | awk -F'[v.]' '{printf "release-% d.% d", $$2, $$3}')
226237# ENVTEST_K8S_VERSION is the version of Kubernetes to use for setting up ENVTEST binaries (i.e. 1.31)
227238ENVTEST_K8S_VERSION ?= $(shell go list -m -f "{{ .Version }}" k8s.io/api | awk -F'[v.]' '{printf "1.% d", $$3}')
228- GOLANGCI_LINT_VERSION ?= v2.1.0
239+ GOLANGCI_LINT_VERSION ?= v2.6.2
229240NILAWAY_VERSION ?= latest
230- MOCKGEN_VERSION ?= v0.5.2
241+ MOCKGEN_VERSION ?= v0.6.0
231242ENVSUBST_VERSION ?=latest
232- GINKGO_VERSION ?= v2.23.4
243+ GINKGO_VERSION ?= v2.25.3
244+ CONVERSION_GEN_VERSION ?= v0.34.0
233245
234246.PHONY : kustomize
235247kustomize : $(KUSTOMIZE ) # # Download kustomize locally if necessary.
@@ -241,6 +253,11 @@ controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessar
241253$(CONTROLLER_GEN ) : $(LOCALBIN )
242254 $(call go-install-tool,$(CONTROLLER_GEN ) ,sigs.k8s.io/controller-tools/cmd/controller-gen,$(CONTROLLER_TOOLS_VERSION ) )
243255
256+ .PHONY : conversion-gen
257+ conversion-gen : $(CONVERSION_GEN ) # # Download conversion-gen locally if necessary.
258+ $(CONVERSION_GEN ) : $(LOCALBIN )
259+ $(call go-install-tool,$(CONVERSION_GEN ) ,k8s.io/code-generator/cmd/conversion-gen,$(CONVERSION_GEN_VERSION ) )
260+
244261.PHONY : setup-envtest
245262setup-envtest : envtest # # Download the binaries required for ENVTEST in the local bin directory.
246263 @echo " Setting up envtest binaries for Kubernetes version $( ENVTEST_K8S_VERSION) ..."
@@ -279,6 +296,11 @@ ginkgo: $(GINKGO) ## Download ginkgo locally if necessary.
279296$(GINKGO ) : $(LOCALBIN )
280297 $(call go-install-tool,$(GINKGO ) ,github.com/onsi/ginkgo/v2/ginkgo,$(GINKGO_VERSION ) )
281298
299+ .PHONY : golangci-lint-kube-api-linter
300+ golangci-lint-kube-api-linter : $(GOLANGCI_LINT_KAL ) # # Build golangci-lint-kal from custom configuration.
301+ $(GOLANGCI_LINT_KAL ) : $(GOLANGCI_LINT )
302+ $(GOLANGCI_LINT ) custom
303+
282304# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
283305# $1 - target path with name of binary
284306# $2 - package url which can be installed
0 commit comments