@@ -24,6 +24,8 @@ KIND_CLUSTER_NAME ?= operator-controller
2424
2525CONTAINER_RUNTIME ?= docker
2626
27+ KUSTOMIZE_BUILD_DIR ?= config/default
28+
2729# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
2830ifeq (,$(shell go env GOBIN) )
2931GOBIN =$(shell go env GOPATH) /bin
@@ -103,7 +105,16 @@ test-unit: $(SETUP_ENVTEST) ## Run the unit tests
103105 eval $$($(SETUP_ENVTEST ) use -p env $(ENVTEST_VERSION ) ) && go test -tags $(GO_BUILD_TAGS ) -count=1 -short $(UNIT_TEST_DIRS ) -coverprofile cover.out
104106
105107e2e : KIND_CLUSTER_NAME=operator-controller-e2e
106- e2e : run kind-load-test-artifacts test-e2e kind-cluster-cleanup # # Run e2e test suite on local kind cluster
108+ e2e : KUSTOMIZE_BUILD_DIR=config/e2e
109+ e2e : GO_BUILD_FLAGS=-cover
110+ e2e : run kind-load-test-artifacts test-e2e # # Run e2e test suite on local kind cluster
111+ # Coverage-instrumented binary produces coverage on termination, so we scale down the manager before gathering the coverage
112+ kubectl -n $(OPERATOR_CONTROLLER_NAMESPACE ) scale deployment/operator-controller-controller-manager --replicas=0
113+ kubectl -n $(OPERATOR_CONTROLLER_NAMESPACE ) run pvc-copy --image busybox --restart=Never --override-type strategic --overrides=' {"spec": {"volumes": [{"name": "data", "persistentVolumeClaim": {"claimName": "e2e-coverage"}}], "containers": [{"name": "pvc-copy", "securityContext": {"runAsUser": 65532, "runAsNonRoot": true, "allowPrivilegeEscalation": false, "seccompProfile": {"type": "RuntimeDefault"}, "capabilities": {"drop": ["ALL"]}}, "volumeMounts": [{"name": "data", "mountPath": "/data"}]}]}}' -- sleep infinity
114+ kubectl -n $(OPERATOR_CONTROLLER_NAMESPACE ) wait --for=condition=ready pod pvc-copy
115+ kubectl -n $(OPERATOR_CONTROLLER_NAMESPACE ) cp pvc-copy:/data/ ./coverage/
116+ go tool covdata textfmt -i=./coverage/ -o e2e-cover.out
117+ $(MAKE ) kind-cluster-cleanup KIND_CLUSTER_NAME=$(KIND_CLUSTER_NAME )
107118
108119kind-load : $(KIND ) # # Loads the currently constructed image onto the cluster
109120 $(KIND ) load docker-image $(IMG ) --name $(KIND_CLUSTER_NAME )
@@ -174,7 +185,7 @@ release: $(GORELEASER) ## Runs goreleaser for the operator-controller. By defaul
174185
175186quickstart : export MANIFEST="https://github.com/operator-framework/operator-controller/releases/download/$(VERSION ) /operator-controller.yaml"
176187quickstart : $(KUSTOMIZE ) generate # # Generate the installation release manifests and scripts
177- $(KUSTOMIZE ) build config/default | sed " s/:devel/:$( VERSION) /g" > operator-controller.yaml
188+ $(KUSTOMIZE ) build $( KUSTOMIZE_BUILD_DIR ) | sed " s/:devel/:$( VERSION) /g" > operator-controller.yaml
178189 envsubst ' $$CATALOGD_VERSION,$$CERT_MGR_VERSION,$$RUKPAK_VERSION,$$MANIFEST' < scripts/install.tpl.sh > install.sh
179190
180191# #@ Deployment
@@ -186,7 +197,7 @@ endif
186197.PHONY : install
187198install : export MANIFEST="./operator-controller.yaml"
188199install : manifests $(KUSTOMIZE ) generate # # Install CRDs into the K8s cluster specified in ~/.kube/config.
189- $(KUSTOMIZE ) build config/default > operator-controller.yaml
200+ $(KUSTOMIZE ) build $( KUSTOMIZE_BUILD_DIR ) > operator-controller.yaml
190201 envsubst ' $$CATALOGD_VERSION,$$CERT_MGR_VERSION,$$RUKPAK_VERSION,$$MANIFEST' < scripts/install.tpl.sh | bash -s
191202
192203.PHONY : uninstall
@@ -196,8 +207,8 @@ uninstall: manifests $(KUSTOMIZE) ## Uninstall CRDs from the K8s cluster specifi
196207.PHONY : deploy
197208deploy : manifests $(KUSTOMIZE ) # # Deploy controller to the K8s cluster specified in ~/.kube/config.
198209 cd config/manager && $(KUSTOMIZE ) edit set image controller=${IMG}
199- $(KUSTOMIZE ) build config/default | kubectl apply -f -
210+ $(KUSTOMIZE ) build $( KUSTOMIZE_BUILD_DIR ) | kubectl apply -f -
200211
201212.PHONY : undeploy
202213undeploy : # # Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
203- $(KUSTOMIZE ) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found ) -f -
214+ $(KUSTOMIZE ) build $( KUSTOMIZE_BUILD_DIR ) | kubectl delete --ignore-not-found=$(ignore-not-found ) -f -
0 commit comments