1818KUBECTL ?= $(shell which kubectl)
1919OPERATOR_SDK ?= $(shell which operator-sdk)
2020OPM ?= $(shell which opm)
21+ KUSTOMIZE ?= $(shell which kustomize)
22+ KUSTOMIZE_VERSION =v3.8.7
2123
2224ENVCRDS_DIR =$(shell pwd) /testcrds
2325
@@ -33,7 +35,9 @@ VERSION ?= $(shell git describe --exact-match 2> /dev/null || \
3335RELEASE_VERSION ?= $(shell cat ./version/version.go | grep "Version =" | awk '{ print $$3}' | tr -d '"')
3436LATEST_VERSION ?= latest
3537OPERATOR_SDK_VERSION =v1.24.0
36- YQ_VERSION =v4.3.1
38+ YQ_VERSION =v4.17.2
39+ DEFAULT_CHANNEL ?= v$(shell cat ./version/version.go | grep "Version =" | awk '{ print $$3}' | tr -d '"' | cut -d '.' -f1,2)
40+ CHANNELS ?= $(DEFAULT_CHANNEL )
3741
3842LOCAL_OS := $(shell uname)
3943ifeq ($(LOCAL_OS ) ,Linux)
@@ -134,6 +138,19 @@ else
134138YQ =$(shell which yq)
135139endif
136140
141+ kustomize : # # Install kustomize
142+ ifeq (, $(shell which kustomize 2>/dev/null) )
143+ @{ \
144+ set -e ;\
145+ mkdir -p bin ;\
146+ echo "Downloading kustomize ...";\
147+ curl -sSLo - https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/$(KUSTOMIZE_VERSION)/kustomize_$(KUSTOMIZE_VERSION)_$(LOCAL_OS)_$(LOCAL_ARCH).tar.gz | tar xzf - -C bin/ ;\
148+ }
149+ KUSTOMIZE =$(realpath ./bin/kustomize)
150+ else
151+ KUSTOMIZE =$(shell which kustomize)
152+ endif
153+
137154operator-sdk :
138155ifneq ($(shell operator-sdk version | cut -d ',' -f1 | cut -d ' :' -f2 | tr -d '"' | xargs | cut -d '.' -f1), v1)
139156 @{ \
@@ -191,6 +208,10 @@ bundle-manifests:
191208 $(KUSTOMIZE ) build config/manifests | $(OPERATOR_SDK ) generate bundle \
192209 -q --overwrite --version $(OPERATOR_VERSION ) $(BUNDLE_METADATA_OPTS )
193210 $(OPERATOR_SDK ) bundle validate ./bundle
211+ $(YQ ) eval-all -i ' .spec.relatedImages = load("config/manifests/bases/operand-deployment-lifecycle-manager.clusterserviceversion.yaml").spec.relatedImages' bundle/manifests/operand-deployment-lifecycle-manager.clusterserviceversion.yaml
212+ # Need to replace fields this way to avoid changing PROJECT name and CSV file name, which may or may not impact CICD automation
213+ $(YQ ) e -i ' .annotations["operators.operatorframework.io.bundle.package.v1"] = "ibm-odlm"' bundle/metadata/annotations.yaml
214+ sed -i' ' s/operand-deployment-lifecycle-manager/ibm-odlm/ bundle.Dockerfile
194215
195216generate-all : manifests kustomize operator-sdk # # Generate bundle manifests, metadata and package manifests
196217 $(OPERATOR_SDK ) generate kustomize manifests -q
@@ -245,8 +266,8 @@ build-operator-image: $(CONFIG_DOCKER_TARGET) ## Build the operator image.
245266 --build-arg GOARCH=$(LOCAL_ARCH ) -f Dockerfile .
246267
247268build-operator-dev-image : # # Build the operator dev image.
248- @echo " Building the $( OPERATOR_IMAGE_NAME) docker image..."
249- @docker build -t $(OPERATOR_IMAGE_NAME ) :$(VERSION ) \
269+ @echo " Building the $( DEV_REGISTRY ) / $( OPERATOR_IMAGE_NAME) docker image..."
270+ @docker build -t $(DEV_REGISTRY ) / $( OPERATOR_IMAGE_NAME ) :$(VERSION ) \
250271 --build-arg VCS_REF=$(VCS_REF ) --build-arg VCS_URL=$(VCS_URL ) \
251272 --build-arg GOARCH=$(LOCAL_ARCH ) -f Dockerfile .
252273
@@ -260,7 +281,6 @@ build-test-operator-image: $(CONFIG_DOCKER_TARGET) ## Build the operator test im
260281
261282build-push-dev-image : build-operator-dev-image # # Build and push the operator dev images.
262283 @echo " Pushing the $( DEV_REGISTRY) /$( OPERATOR_IMAGE_NAME) :$( VERSION) docker image to $( DEV_REGISTRY) ..."
263- @docker tag $(OPERATOR_IMAGE_NAME ) :$(VERSION ) $(DEV_REGISTRY ) /$(OPERATOR_IMAGE_NAME ) :$(VERSION )
264284 @docker push $(DEV_REGISTRY ) /$(OPERATOR_IMAGE_NAME ) :$(VERSION )
265285
266286build-push-image : $(CONFIG_DOCKER_TARGET ) build-operator-image # # Build and push the operator images.
@@ -269,12 +289,9 @@ build-push-image: $(CONFIG_DOCKER_TARGET) build-operator-image ## Build and pus
269289 @docker push $(ARTIFACTORYA_REGISTRY ) /$(OPERATOR_IMAGE_NAME ) -$(LOCAL_ARCH ) :$(VERSION )
270290
271291build-push-bundle-image : yq
272- @cp -f bundle/manifests/operand-deployment-lifecycle-manager.clusterserviceversion.yaml /tmp/operand-deployment-lifecycle-manager.clusterserviceversion.yaml
273- $(YQ ) eval -i ' del(.spec.replaces)' bundle/manifests/operand-deployment-lifecycle-manager.clusterserviceversion.yaml
274292 @docker build -f bundle.Dockerfile -t $(QUAY_REGISTRY ) /$(BUNDLE_IMAGE_NAME ) -$(LOCAL_ARCH ) :$(VERSION ) .
275293 @echo " Pushing the $( BUNDLE_IMAGE_NAME) docker image for $( LOCAL_ARCH) ..."
276294 @docker push $(QUAY_REGISTRY ) /$(BUNDLE_IMAGE_NAME ) -$(LOCAL_ARCH ) :$(VERSION )
277- @mv /tmp/operand-deployment-lifecycle-manager.clusterserviceversion.yaml bundle/manifests/operand-deployment-lifecycle-manager.clusterserviceversion.yaml
278295
279296build-catalog-source :
280297 @opm -u docker index add --bundles $(QUAY_REGISTRY ) /$(BUNDLE_IMAGE_NAME ) -$(LOCAL_ARCH ) :$(VERSION ) --tag $(QUAY_REGISTRY ) /$(OPERATOR_IMAGE_NAME ) -catalog:$(VERSION )
@@ -285,6 +302,12 @@ build-catalog: build-push-bundle-image build-catalog-source
285302multiarch-image : $(CONFIG_DOCKER_TARGET ) # # Generate multiarch images for operator image.
286303 @MAX_PULLING_RETRY=20 RETRY_INTERVAL=30 common/scripts/multiarch_image.sh $(ARTIFACTORYA_REGISTRY ) $(OPERATOR_IMAGE_NAME ) $(VERSION ) $(RELEASE_VERSION )
287304
305+ run-bundle :
306+ $(OPERATOR_SDK ) run bundle $(QUAY_REGISTRY ) /$(BUNDLE_IMAGE_NAME ) -$(LOCAL_ARCH ) :$(VERSION ) --install-mode OwnNamespace
307+
308+ cleanup-bundle :
309+ $(OPERATOR_SDK ) cleanup ibm-odlm
310+
288311# #@ Help
289312help : # # Display this help
290313 @echo " Usage:\n make \033[36m<target>\033[0m"
0 commit comments