@@ -29,8 +29,6 @@ ARCH = $(shell go env GOARCH)
2929# Image URL to use all building/pushing image targets
3030IMG ?= quay.io/3scale/3scale-operator:master
3131
32- CRD_OPTIONS ?= "crd:crdVersions=v1"
33-
3432GO ?= go
3533KUBECTL ?= kubectl
3634DOCKER ?= docker
@@ -64,14 +62,17 @@ PROMETHEUS_RULES_TARGETS = $(foreach pr,$(PROMETHEUS_RULES),$(PROJECT_PATH)/doc/
6462PROMETHEUS_RULES_DEPS = $(shell find $(PROJECT_PATH ) /pkg/3scale/amp/component -name '* .go')
6563PROMETHEUS_RULES_NAMESPACE ?= "__NAMESPACE__"
6664
65+ .PHONY : all
6766all : manager
6867
6968# Run all tests
69+ .PHONY : test
7070test : test-unit test-e2e test-crds test-manifests-version
7171
7272# Run unit tests
7373TEST_UNIT_PKGS = $(shell $(GO ) list ./... | grep -E 'github.com/3scale/3scale-operator/pkg|github.com/3scale/3scale-operator/apis|github.com/3scale/3scale-operator/test/unitcontrollers|github.com/3scale/3scale-operator/controllers/capabilities')
7474TEST_UNIT_COVERPKGS = $(shell $(GO ) list ./... | grep -v github.com/3scale/3scale-operator/test | tr "\n" ",") # Exclude test directories as coverpkg does not accept only-tests packages
75+ .PHONY: test-unit
7576test-unit : clean-cov generate fmt vet manifests
7677 mkdir -p " $( PROJECT_PATH) /_output"
7778 $(GO ) test -v $(TEST_UNIT_PKGS ) -covermode=count -coverprofile $(PROJECT_PATH ) /_output/unit.cov -coverpkg=$(TEST_UNIT_COVERPKGS )
@@ -80,18 +81,21 @@ $(PROJECT_PATH)/_output/unit.cov: test-unit
8081
8182# Run CRD tests
8283TEST_CRD_PKGS = $(shell $(GO ) list ./... | grep 'github.com/3scale/3scale-operator/test/crds')
84+ .PHONY : test-crds
8385test-crds : generate fmt vet manifests
8486 $(GO ) test -v $(TEST_CRD_PKGS )
8587
8688TEST_MANIFESTS_VERSION_PKGS = $(shell $(GO ) list ./... | grep 'github.com/3scale/3scale-operator/test/manifests-version')
8789# # test-manifests-version: Run manifest version checks
90+ .PHONY : test-manifests-version
8891test-manifests-version :
8992 $(GO ) test -v $(TEST_MANIFESTS_VERSION_PKGS )
9093
9194# Run e2e tests
9295TEST_E2E_PKGS_APPS = $(shell $(GO ) list ./... | grep 'github.com/3scale/3scale-operator/controllers/apps')
9396TEST_E2E_PKGS_CAPABILITIES = $(shell $(GO ) list ./... | grep 'github.com/3scale/3scale-operator/controllers/capabilities')
9497ENVTEST_ASSETS_DIR =$(PROJECT_PATH ) /testbin
98+ .PHONY : test-e2e
9599test-e2e : generate fmt vet manifests
96100 mkdir -p ${ENVTEST_ASSETS_DIR}
97101 test -f $(ENVTEST_ASSETS_DIR ) /setup-envtest.sh || curl -sSLo $(ENVTEST_ASSETS_DIR ) /setup-envtest.sh https://raw.githubusercontent.com/kubernetes-sigs/controller-runtime/v0.8.0/hack/setup-envtest.sh
@@ -100,10 +104,12 @@ test-e2e: generate fmt vet manifests
100104
101105
102106# Build manager binary
107+ .PHONY : manager
103108manager : generate fmt vet
104109 $(GO ) build -o bin/manager main.go
105110
106111# Run against the configured Kubernetes cluster in ~/.kube/config
112+ .PHONY : run
107113run : export WATCH_NAMESPACE=$(LOCAL_RUN_NAMESPACE )
108114run : export THREESCALE_DEBUG=1
109115run : export PREFLIGHT_CHECKS_BYPASS=true
@@ -172,7 +178,7 @@ kustomize: $(KUSTOMIZE)
172178OPERATOR_SDK = $(PROJECT_PATH ) /bin/operator-sdk
173179# Note: release file patterns changed after v1.2.0
174180# More info https://sdk.operatorframework.io/docs/installation/
175- OPERATOR_SDK_VERSION =v1.11.0
181+ OPERATOR_SDK_VERSION =v1.20.1
176182$(OPERATOR_SDK ) :
177183 curl -sSL https://github.com/operator-framework/operator-sdk/releases/download/$(OPERATOR_SDK_VERSION ) /operator-sdk_$(OS ) _$(ARCH ) -o $(OPERATOR_SDK )
178184 chmod +x $(OPERATOR_SDK )
@@ -187,28 +193,44 @@ $(GO_BINDATA):
187193.PHONY : go-bindata
188194go-bindata : $(GO_BINDATA )
189195
196+ # #@ Deployment
197+
198+ ifndef ignore-not-found
199+ ignore-not-found = false
200+ endif
201+
190202# Install CRDs into a cluster
203+ .PHONY : install
191204install : manifests $(KUSTOMIZE )
192205 $(KUSTOMIZE ) build config/crd | $(KUBECTL ) create -f - || $(KUSTOMIZE ) build config/crd | $(KUBECTL ) replace -f -
193206
194207# Uninstall CRDs from a cluster
208+ .PHONY : uninstall
195209uninstall : manifests $(KUSTOMIZE )
196- $(KUSTOMIZE ) build config/crd | $(KUBECTL ) delete -f -
210+ $(KUSTOMIZE ) build config/crd | $(KUBECTL ) delete --ignore-not-found= $( ignore-not-found ) - f -
197211
198212# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
213+ .PHONY : deploy
199214deploy : manifests $(KUSTOMIZE )
200215 cd config/manager && $(KUSTOMIZE ) edit set image controller=${IMG}
201216 $(KUSTOMIZE ) build config/default | $(KUBECTL ) apply -f -
202217
218+ .PHONY : undeploy
219+ undeploy : # # Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
220+ $(KUSTOMIZE ) build config/default | $(KUBECTL ) delete --ignore-not-found=$(ignore-not-found ) -f -
221+
203222# Generate manifests e.g. CRD, RBAC etc.
223+ .PHONY : manifests
204224manifests : $(CONTROLLER_GEN )
205- $(CONTROLLER_GEN ) $( CRD_OPTIONS ) rbac:roleName=manager-role webhook paths=" ./..." output:crd:artifacts:config=config/crd/bases
225+ $(CONTROLLER_GEN ) rbac:roleName=manager-role crd webhook paths=" ./..." output:crd:artifacts:config=config/crd/bases
206226
207227# Run go fmt against code
228+ .PHONY : fmt
208229fmt :
209230 $(GO ) fmt ./...
210231
211232# Run go vet against code
233+ .PHONY : vet
212234vet :
213235 $(GO ) vet ./...
214236
@@ -326,6 +348,7 @@ catalog-build: opm
326348catalog-push : # # Push the catalog image.
327349 $(MAKE ) docker-push IMG=$(CATALOG_IMG )
328350
351+ .PHONY : download
329352download :
330353 @echo Download go.mod dependencies
331354 @$(GO ) mod download
@@ -339,6 +362,7 @@ endif
339362 license_finder report --decisions-file=$(DEPENDENCY_DECISION_FILE) --quiet --format=xml > licenses.xml
340363
341364# # licenses-check: Check license compliance of dependencies
365+ .PHONY : licenses-check
342366licenses-check :
343367ifndef LICENSEFINDERBINARY
344368 $(error "license-finder is not available please install: gem install license_finder --version 5.7.1")
0 commit comments