@@ -81,6 +81,14 @@ generate-deepcopy: $(DEEPCOPY_GEN_TARGETS) ## Generate code containing DeepCopy,
8181api/% /zz_generated.deepcopy.go : bin/controller-gen $(DEEPCOPY_GEN_INPUTS )
8282 controller-gen object:headerFile=" hack/boilerplate.go.txt" paths=" ./..."
8383
84+ CONVERSION_GEN_TARGET =$(shell find api -type d -name "v* 1" -exec echo {}\/zz_generated.conversion.go \;)
85+ CONVERSION_GEN_INPUTS =$(shell find ./api -name "* test* " -prune -o -name "* zz_generated* " -prune -o -type f -print)
86+ .PHONY : generate-conversion
87+ generate-conversion : $(CONVERSION_GEN_TARGET ) # # Generate code to convert api/v1beta1 to api/v1beta2
88+ api/% /zz_generated.conversion.go : bin/conversion-gen $(CONVERSION_GEN_INPUTS )
89+ conversion-gen --go-header-file " ./hack/boilerplate.go.txt" --input-dirs " ./api/v1beta1" \
90+ --output-base " ." --output-file-base=" zz_generated.conversion" --skip-unsafe=true
91+
8492# #@ Build
8593
8694MANAGER_BIN_INPUTS =$(shell find ./controllers ./api ./pkg -name "* mock* " -prune -o -name "* test* " -prune -o -type f -print) main.go go.mod go.sum
@@ -97,13 +105,13 @@ bin/manager-linux-amd64: $(MANAGER_BIN_INPUTS)
97105 -o bin/manager-linux-amd64 main.go
98106
99107.PHONY : run
100- run : generate-deepcopy # # Run a controller from your host.
108+ run : generate-deepcopy generate-conversion # # Run a controller from your host.
101109 go run ./main.go
102110
103111# Using a flag file here as docker build doesn't produce a target file.
104112DOCKER_BUILD_INPUTS =$(MANAGER_BIN_INPUTS ) Dockerfile
105113.PHONY : docker-build
106- docker-build : generate-deepcopy build-for-docker .dockerflag.mk # # Build docker image containing the controller manager.
114+ docker-build : generate-deepcopy generate-conversion build-for-docker .dockerflag.mk # # Build docker image containing the controller manager.
107115.dockerflag.mk : $(DOCKER_BUILD_INPUTS )
108116 docker build -t ${IMG} .
109117 @touch .dockerflag.mk
@@ -137,7 +145,7 @@ lint: bin/golangci-lint bin/staticcheck generate-mocks ## Run linting for the pr
137145# #@ Deployment
138146
139147.PHONY : deploy
140- deploy : generate-deepcopy manifests bin/kustomize # # Deploy controller to the K8s cluster specified in ~/.kube/config.
148+ deploy : generate-deepcopy generate-conversion manifests bin/kustomize # # Deploy controller to the K8s cluster specified in ~/.kube/config.
141149 cd config/manager && kustomize edit set image controller=${IMG}
142150 kustomize build config/default | kubectl apply -f -
143151
@@ -147,9 +155,11 @@ undeploy: bin/kustomize ## Undeploy controller from the K8s cluster specified in
147155# #@ Binaries
148156
149157.PHONY : binaries
150- binaries : bin/controller-gen bin/kustomize bin/ginkgo bin/golangci-lint bin/staticcheck bin/mockgen bin/kubectl # # Locally install all needed bins.
158+ binaries : bin/controller-gen bin/conversion-gen bin/ kustomize bin/ginkgo bin/golangci-lint bin/staticcheck bin/mockgen bin/kubectl # # Locally install all needed bins.
151159bin/controller-gen : # # Install controller-gen to bin.
152160 GOBIN=
$(PROJECT_DIR ) /bin go install sigs.k8s.io/controller-tools/cmd/
[email protected] 161+ bin/conversion-gen : # # Install conversion-gen to bin.
162+ GOBIN=
$(PROJECT_DIR ) /bin go install k8s.io/code-generator/cmd/
[email protected] 153163bin/golangci-lint : # # Install golangci-lint to bin.
154164 GOBIN=
$(PROJECT_DIR ) /bin go install github.com/golangci/golangci-lint/cmd/
[email protected] 155165bin/staticcheck : # # Install staticcheck to bin.
@@ -186,6 +196,7 @@ export KUBEBUILDER_ASSETS=$(PROJECT_DIR)/bin
186196
187197.PHONY : test
188198test : generate-mocks lint bin/ginkgo bin/kubectl bin/kube-apiserver bin/etcd # # Run tests. At the moment this is only unit tests.
199+ @./hack/testing_ginkgo_recover_statements.sh --add # Add ginkgo.GinkgoRecover() statements to controllers.
189200 @# The following is a slightly funky way to make sure the ginkgo statements are removed regardless the test results.
190201 @ginkgo_v2 --label-filter=" !integ" --cover -coverprofile cover.out --covermode=atomic -v ./api/... ./controllers/... ./pkg/...; EXIT_STATUS=$$? ; \
191202 ./hack/testing_ginkgo_recover_statements.sh --remove; exit $$ EXIT_STATUS
@@ -198,8 +209,8 @@ pkg/mocks/mock%.go: $(shell find ./pkg/cloud -type f -name "*test*" -prune -o -p
198209# #@ Tilt
199210
200211.PHONY : tilt-up
201- tilt-up : cluster-api kind-cluster cluster-api/tilt-settings.json manifests cloud-config # # Setup and run tilt for development.
202- export CLOUDSTACK_B64ENCODED_SECRET= $$( base64 -w0 -i cloud-config 2>/dev/null || base64 -b 0 -i cloud-config ) && cd cluster-api && tilt up
212+ tilt-up : cluster-api kind-cluster cluster-api/tilt-settings.json manifests # # Setup and run tilt for development.
213+ cd cluster-api && tilt up
203214
204215.PHONY : kind-cluster
205216kind-cluster : cluster-api # # Create a kind cluster with a local Docker repository.
@@ -213,7 +224,7 @@ cluster-api/tilt-settings.json: hack/tilt-settings.json cluster-api
213224
214225# #@ End-to-End Testing
215226
216- CLUSTER_TEMPLATES_INPUT_FILES =$(shell find test/e2e/data/infrastructure-cloudstack/* /cluster-template* /* test/e2e/data/infrastructure-cloudstack/* /bases/* -type f)
227+ CLUSTER_TEMPLATES_INPUT_FILES =$(shell find test/e2e/data/infrastructure-cloudstack/v1beta2/ * /cluster-template* /* test/e2e/data/infrastructure-cloudstack/* /bases/* -type f)
217228CLUSTER_TEMPLATES_OUTPUT_FILES =$(shell find test/e2e/data/infrastructure-cloudstack -type d -name "cluster-template* " -exec echo {}.yaml \;)
218229.PHONY : e2e-cluster-templates
219230e2e-cluster-templates : $(CLUSTER_TEMPLATES_OUTPUT_FILES ) # # Generate cluster template files for e2e testing.
@@ -225,6 +236,7 @@ e2e-essentials: bin/ginkgo_v1 e2e-cluster-templates kind-cluster ## Fulfill esse
225236
226237JOB ?= .*
227238run-e2e : e2e-essentials # # Run e2e testing. JOB is an optional REGEXP to select certainn test cases to run. e.g. JOB=PR-Blocking, JOB=Conformance
239+ kubectl apply -f cloud-config.yaml && \
228240 cd test/e2e && \
229241 ginkgo_v1 -v -trace -tags=e2e -focus=$(JOB ) -skip=Conformance -nodes=1 -noColor=false ./... -- \
230242 -e2e.artifacts-folder=${PROJECT_DIR} /_artifacts \
0 commit comments