@@ -40,12 +40,23 @@ IMAGE_TAG_BASE ?= $(IMAGE)
4040# You can use it as an arg. (E.g make bundle-build BUNDLE_IMG=<some-registry>/<project-name-bundle>:<tag>)
4141BUNDLE_IMG ?= $(IMAGE_TAG_BASE ) -bundle:$(VERSION )
4242
43+ # BUNDLE_GEN_FLAGS are the flags passed to the operator-sdk generate bundle command
44+ BUNDLE_GEN_FLAGS ?= -q --overwrite --version $(VERSION ) $(BUNDLE_METADATA_OPTS )
45+
46+ # USE_IMAGE_DIGESTS defines if images are resolved via tags or digests
47+ # You can enable this value if you would like to use SHA Based Digests
48+ # To enable set flag to true
49+ USE_IMAGE_DIGESTS ?= false
50+ ifeq ($(USE_IMAGE_DIGESTS ) , true)
51+ BUNDLE_GEN_FLAGS += --use-image-digests
52+ endif
53+
4354# Image URL to use all building/pushing image targets
4455IMG ?= $(IMAGE ) :$(VERSION )
4556
4657# Set the Operator SDK version to use.
4758# This is useful for CI or a project to utilize a specific version of the operator-sdk toolkit.
48- OPERATOR_SDK_VERSION ?= v1.22.2
59+ OPERATOR_SDK_VERSION ?= v1.32.0
4960
5061
5162# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
6172SHELL = /usr/bin/env bash -o pipefail
6273.SHELLFLAGS = -ec
6374
75+ .PHONY : all
6476all : build
6577
6678# #@ General
@@ -76,42 +88,57 @@ all: build
7688# More info on the awk command:
7789# http://linuxcommand.org/lc3_adv_awk.php
7890
91+ .PHONY : help
7992help : # # Display this help.
8093 @awk ' BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST )
8194
8295# #@ Development
8396
97+ .PHONY : manifests
8498manifests : controller-gen # # Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
8599 $(CONTROLLER_GEN ) rbac:roleName=manager-role webhook crd paths=" ./..." output:crd:artifacts:config=config/crd/bases
86100
101+ .PHONY : generate
87102generate : controller-gen # # Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
88103 $(CONTROLLER_GEN ) object:headerFile=" hack/boilerplate.go.txt" paths=" ./..."
89104
105+ .PHONY : fmt
90106fmt : # # Run go fmt against code.
91107 go fmt ./...
92108
109+ .PHONY : vet
93110vet : # # Run go vet against code.
94111 go vet ./...
95112
113+ .PHONY : test-all
96114test-all : manifests generate fmt vet # # Run all tests.
97115 go test -timeout 1h ./... -coverprofile cover.out
98116
117+ .PHONY : test-e2e
99118test-e2e : manifests generate fmt vet # # Run e2e tests.
100119 go test -p 1 -timeout 1h ./test/e2e -coverprofile cover.out -ginkgo.v
101120 go test -p 1 -timeout 1h ./test/nondefaulte2e -coverprofile cover.out -ginkgo.v
102121
122+ .PHONY : test-metrics
103123test-metrics :
104124 go test -timeout 30m ./test/e2e -ginkgo.focus=" Argo CD metrics controller" -coverprofile cover.out -ginkgo.v
105125
126+
127+ .PHONY : test-route
106128test-route :
107129 go test -timeout 30m ./test/e2e -ginkgo.focus=" Argo CD ConsoleLink controller" -coverprofile cover.out -ginkgo.v
108130
131+
132+ .PHONY : test-gitopsservice
109133test-gitopsservice :
110134 go test -p 1 -timeout 1h ./test/e2e -ginkgo.focus=" GitOpsServiceController" -coverprofile cover.out -ginkgo.v
111135
136+
137+ .PHONY : test-gitopsservice-nondefault
112138test-gitopsservice-nondefault :
113139 go test -p 1 -timeout 30m ./test/nondefaulte2e -ginkgo.focus=" GitOpsServiceNoDefaultInstall" -coverprofile cover.out -ginkgo.v
114140
141+ .PHONY : test
115142test : manifests generate fmt vet # # Run unit tests.
116143 go test ` go list ./... | grep -v test` -coverprofile cover.out
117144
@@ -142,15 +169,19 @@ e2e-non-olm-tests-all:
142169
143170# #@ Build
144171
172+ .PHONY : build
145173build : generate fmt vet # # Build manager binary.
146174 go build -o bin/manager main.go
147175
176+ .PHONY : run
148177run : manifests generate fmt vet # # Run a controller from your host.
149178 REDIS_CONFIG_PATH=" build/redis" go run ./main.go
150179
180+ .PHONY : docker-build
151181docker-build : test # # Build docker image with the manager.
152182 docker build -t ${IMG} .
153183
184+ .PHONY : docker-push
154185docker-push : # # Push docker image with the manager.
155186 docker push ${IMG}
156187
@@ -178,31 +209,40 @@ OPERATOR_SDK = $(shell which operator-sdk)
178209endif
179210endif
180211
212+ ifndef ignore-not-found
213+ ignore-not-found = false
214+ endif
181215
182216# #@ Deployment
183217
218+ .PHONY : install
184219install : manifests kustomize # # Install CRDs into the K8s cluster specified in ~/.kube/config.
185220 # # TODO: Remove sed usage after all v1alpha1 references are updated to v1beta1 in codebase.
186221 # # For local testing, conversion webhook defined in crd makes call to webhook for each v1alpha1 reference
187222 # # causing failures as we don't set up the webhook for local testing.
188223 $(KUSTOMIZE ) build config/crd | sed ' /conversion:/,/- v1beta1/d' | kubectl apply --server-side=true -f -
189224
225+ .PHONY : uninstall
190226uninstall : manifests kustomize # # Uninstall CRDs from the K8s cluster specified in ~/.kube/config.
191227 $(KUSTOMIZE ) build config/crd | kubectl delete --ignore-not-found=true -f -
192228
229+ .PHONY : deploy
193230deploy : manifests kustomize # # Deploy controller to the K8s cluster specified in ~/.kube/config.
194231 cd config/manager && $(KUSTOMIZE ) edit set image controller=${IMG}
195232 $(KUSTOMIZE ) build config/default | kubectl apply --server-side=true -f -
196233
234+ .PHONY : undeploy
197235undeploy : # # Undeploy controller from the K8s cluster specified in ~/.kube/config.
198236 $(KUSTOMIZE ) build config/default | kubectl delete --ignore-not-found=true -f -
199237
200238
201239CONTROLLER_GEN = $(shell pwd) /bin/controller-gen
240+ .PHONY : controller-gen
202241controller-gen : # # Download controller-gen locally if necessary.
203242 $(call go-get-tool,$(CONTROLLER_GEN ) ,sigs.k8s.io/controller-tools/cmd/controller-gen@v0.14.0)
204243
205244KUSTOMIZE = $(shell pwd) /bin/kustomize
245+ .PHONY : kustomize
206246kustomize : # # Download kustomize locally if necessary.
207247 $(call go-get-tool,$(KUSTOMIZE ) ,sigs.k8s.io/kustomize/kustomize/v4@v4.5.2)
208248
@@ -226,7 +266,7 @@ endef
226266bundle : operator-sdk manifests kustomize # # Generate bundle manifests and metadata, then validate generated files.
227267 $(OPERATOR_SDK ) generate kustomize manifests -q
228268 cd config/manager && $(KUSTOMIZE ) edit set image controller=$(IMG )
229- $(KUSTOMIZE ) build config/manifests | $(OPERATOR_SDK ) generate bundle -q --overwrite --version $( VERSION ) $( BUNDLE_METADATA_OPTS )
269+ $(KUSTOMIZE ) build config/manifests | $(OPERATOR_SDK ) generate bundle $( BUNDLE_GEN_FLAGS )
230270 $(OPERATOR_SDK ) bundle validate ./bundle
231271
232272.PHONY : bundle-build
@@ -246,7 +286,7 @@ ifeq (,$(shell which opm 2>/dev/null))
246286 set -e ;\
247287 mkdir -p $(dir $(OPM)) ;\
248288 OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \
249- curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.15.1 /$${OS}-$${ARCH}-opm ;\
289+ curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.23.0 /$${OS}-$${ARCH}-opm ;\
250290 chmod +x $(OPM) ;\
251291 }
252292else
0 commit comments