@@ -246,11 +246,41 @@ test-unit: $(SETUP_ENVTEST) envtest-k8s-bins #HELP Run the unit tests
246
246
$(UNIT_TEST_DIRS ) \
247
247
-test.gocoverdir=$(COVERAGE_UNIT_DIR )
248
248
249
+ TEST_OPERATOR_DIR =./testdata/operators/test-operator
250
+
251
+ .PHONY : test-operator-test-unit
252
+ test-operator-test-unit : $(SETUP_ENVTEST ) envtest-k8s-bins
253
+ KUBEBUILDER_ASSETS=" $( shell $( SETUP_ENVTEST) use -p path $( ENVTEST_VERSION) $( SETUP_ENVTEST_BIN_DIR_OVERRIDE) ) " \
254
+ CGO_ENABLED=1 go test -tags ' $(GO_BUILD_TAGS)' -count=1 -race -short $(TEST_OPERATOR_DIR ) /...
255
+
256
+ .PHONY : test-operator-build-controllers
257
+ test-operator-build-controllers :
258
+ go build $(GO_BUILD_FLAGS ) $(GO_BUILD_EXTRA_FLAGS ) -tags ' $(GO_BUILD_TAGS)' -ldflags ' $(GO_BUILD_LDFLAGS)' -gcflags ' $(GO_BUILD_GCFLAGS)' -asmflags ' $(GO_BUILD_ASMFLAGS)' -o ./testdata/images/controllers/test-operator/v1.0.0/manager $(TEST_OPERATOR_DIR ) /v1/cmd/main.go
259
+ go build $(GO_BUILD_FLAGS ) $(GO_BUILD_EXTRA_FLAGS ) -tags ' $(GO_BUILD_TAGS)' -ldflags ' $(GO_BUILD_LDFLAGS)' -gcflags ' $(GO_BUILD_GCFLAGS)' -asmflags ' $(GO_BUILD_ASMFLAGS)' -o ./testdata/images/controllers/test-operator/v2.0.0/manager $(TEST_OPERATOR_DIR ) /v2/cmd/main.go
260
+
261
+ .PHONY : test-operator-generate-manifests
262
+ test-operator-generate-manifests : $(CONTROLLER_GEN )
263
+ # generate resources crds
264
+ $(CONTROLLER_GEN ) --load-build-tags=$(GO_BUILD_TAGS ) crd paths="$(TEST_OPERATOR_DIR ) /api/v1/..." output :dir=$(TEST_OPERATOR_DIR ) /charts/v1/crds
265
+ $(CONTROLLER_GEN ) --load-build-tags=$(GO_BUILD_TAGS ) crd paths="$(TEST_OPERATOR_DIR ) /api/..." output :dir=$(TEST_OPERATOR_DIR ) /charts/v2/crds
266
+
267
+ # generate other resources
268
+ $(CONTROLLER_GEN ) --load-build-tags=$(GO_BUILD_TAGS ) rbac :roleName=test-operator-manager-role paths="$(TEST_OPERATOR_DIR ) /v1/..." output:dir=$(TEST_OPERATOR_DIR ) /charts/v1/templates
269
+ $(CONTROLLER_GEN ) --load-build-tags=$(GO_BUILD_TAGS ) rbac :roleName=test-operator-manager-role webhook paths=".$(TEST_OPERATOR_DIR ) /v2/..." output:dir=$(TEST_OPERATOR_DIR ) /charts/v2/templates
270
+
271
+ .PHONY : test-operator-generate-bundles
272
+ test-operator-generate-bundles : test-operator-generate-manifests $(OPERATOR_SDK )
273
+ # generate bundles
274
+ helm template --include-crds $(TEST_OPERATOR_DIR ) /charts/v1 | $(OPERATOR_SDK ) generate bundle -q --channels beta --version 1.0.0 --package test --output-dir ./testdata/images/bundles/test-operator/v1.0.0
275
+ helm template --include-crds --set=configmap.shouldNotTemplate=true $(TEST_OPERATOR_DIR ) /charts/v1 | $(OPERATOR_SDK ) generate bundle -q --channels beta --version 1.3.0 --package test --output-dir ./testdata/images/bundles/test-operator/v1.3.0
276
+ helm template --include-crds $(TEST_OPERATOR_DIR ) /charts/v2 | $(OPERATOR_SDK ) generate bundle -q --channels beta --version 2.0.0 --package test --output-dir ./testdata/images/bundles/test-operator/v2.0.0
277
+ rm -rf bundle.Dockerfile
278
+
249
279
.PHONY : image-registry
250
280
E2E_REGISTRY_IMAGE =localhost/e2e-test-registry:devel
251
281
image-registry : export GOOS=linux
252
282
image-registry : export GOARCH=amd64
253
- image-registry : # # Build the testdata catalog used for e2e tests and push it to the image registry
283
+ image-registry : test-operator-build-controllers test-operator-generate-bundles # # Build the testdata catalog used for e2e tests and push it to the image registry
254
284
go build $(GO_BUILD_FLAGS ) $(GO_BUILD_EXTRA_FLAGS ) -tags ' $(GO_BUILD_TAGS)' -ldflags ' $(GO_BUILD_LDFLAGS)' -gcflags ' $(GO_BUILD_GCFLAGS)' -asmflags ' $(GO_BUILD_ASMFLAGS)' -o ./testdata/push/bin/push ./testdata/push/push.go
255
285
$(CONTAINER_RUNTIME ) build -f ./testdata/Dockerfile -t $(E2E_REGISTRY_IMAGE ) ./testdata
256
286
$(CONTAINER_RUNTIME ) save $(E2E_REGISTRY_IMAGE ) | $(KIND ) load image-archive /dev/stdin --name $(KIND_CLUSTER_NAME )
0 commit comments