@@ -27,6 +27,8 @@ OCP_VERSION ?= 4.14
2727YQ_API_VERSION = v4
2828YQ_VERSION = v4.42.1
2929
30+ BLUE_ICON_PATH = "./config/assets/nmo_blue_icon.png"
31+
3032# IMAGE_REGISTRY used to indicate the registery/group for the operator, bundle and catalog
3133IMAGE_REGISTRY ?= quay.io/medik8s
3234export IMAGE_REGISTRY
@@ -202,7 +204,7 @@ bundle-run: operator-sdk ## Run bundle image. Default NS is "openshift-workload-
202204 $(OPERATOR_SDK ) -n $(OPERATOR_NAMESPACE ) run bundle $(BUNDLE_IMG )
203205
204206.PHONY : bundle-run-update
205- bundle-run-update : operator-sdk # # Update bundle image.
207+ bundle-run-update : operator-sdk # # Update bundle image.
206208# An older bundle image CSV should exist in the cluster, and in the same namespace,
207209# Default NS is "openshift-workload-availability", redefine OPERATOR_NAMESPACE to override it.
208210 $(OPERATOR_SDK) -n $(OPERATOR_NAMESPACE) run bundle-upgrade $(BUNDLE_IMG)
@@ -213,7 +215,7 @@ bundle-cleanup: operator-sdk ## Remove bundle installed via bundle-run
213215
214216# #@ Bundle Creation Addition
215217# # Some addition to bundle creation in the bundle
216- DEFAULT_ICON_BASE64 := $(shell base64 --wrap=0 ./config/assets/nmo_blue_icon.png )
218+ DEFAULT_ICON_BASE64 := $(shell base64 --wrap=0 ${BLUE_ICON_PATH} )
217219export ICON_BASE64 ?= ${DEFAULT_ICON_BASE64}
218220export CSV ?= "./bundle/manifests/$(OPERATOR_NAME ) .clusterserviceversion.yaml"
219221
@@ -347,7 +349,7 @@ kustomize: ## Download kustomize locally if necessary.
347349 $(call go-install-tool,$(KUSTOMIZE ) ,$(KUSTOMIZE_DIR ) ,sigs.k8s.io/kustomize/kustomize/$(KUSTOMIZE_VERSION ) )
348350
349351.PHONY : controller-gen
350- controller-gen : # # Download controller-gen locally if necessary.
352+ controller-gen : # # Download controller-gen locally if necessary.
351353 $(call go-install-tool,$(CONTROLLER_GEN ) ,$(CONTROLLER_GEN_DIR ) ,sigs.k8s.io/controller-tools/cmd/controller-gen@${CONTROLLER_GEN_VERSION})
352354
353355.PHONY : envtest
@@ -397,7 +399,7 @@ bundle: manifests operator-sdk kustomize ## Generate bundle manifests and metada
397399bundle-k8s : bundle # Generate bundle manifests and metadata for Kubernetes, then validate generated files.
398400 $(KUSTOMIZE ) build config/manifests-k8s | $(OPERATOR_SDK ) generate bundle $(BUNDLE_GEN_FLAGS )
399401 $(MAKE ) bundle-validate
400-
402+
401403.PHONY : bundle-validate
402404bundle-validate : operator-sdk # # Validate the bundle directory with additional validators (suite=operatorframework), such as Kubernetes deprecated APIs (https://kubernetes.io/docs/reference/using-api/deprecation-guide/) based on bundle.CSV.Spec.MinKubeVersion
403405 $(OPERATOR_SDK ) bundle validate ./bundle --select-optional suite=operatorframework
@@ -430,9 +432,21 @@ define url-install-tool
430432 }
431433endef
432434
433- ifneq ($(origin CATALOG_BASE_IMG ) , undefined)
434- FROM_INDEX_OPT := --from-index $(CATALOG_BASE_IMG )
435- endif
435+ # Build a file-based catalog image
436+ # https://docs.openshift.com/container-platform/4.14/operators/admin/olm-managing-custom-catalogs.html#olm-managing-custom-catalogs-fb
437+ # NOTE: CATALOG_DIR and CATALOG_DOCKERFILE items won't be deleted in case of recipe's failure
438+ CATALOG_DIR := catalog
439+ CATALOG_DOCKERFILE := ${CATALOG_DIR}.Dockerfile
440+ CATALOG_INDEX := $(CATALOG_DIR ) /index.yaml
441+
442+ .PHONY : add_channel_entry_for_the_bundle
443+ add_channel_entry_for_the_bundle :
444+ @echo " ---" >> ${CATALOG_INDEX}
445+ @echo " schema: olm.channel" >> ${CATALOG_INDEX}
446+ @echo " package: ${OPERATOR_NAME} " >> ${CATALOG_INDEX}
447+ @echo " name: ${CHANNELS} " >> ${CATALOG_INDEX}
448+ @echo " entries:" >> ${CATALOG_INDEX}
449+ @echo " - name: ${OPERATOR_NAME} .v${VERSION} " >> ${CATALOG_INDEX}
436450
437451.PHONY : build-tools
438452build-tools : # # Download & build all the tools locally if necessary.
@@ -442,8 +456,23 @@ build-tools: ## Download & build all the tools locally if necessary.
442456# This recipe invokes 'opm' in 'semver' bundle add mode. For more information on add modes, see:
443457# https://github.com/operator-framework/community-operators/blob/7f1438c/docs/packaging-operator.md#updating-your-existing-operator
444458.PHONY : catalog-build
445- catalog-build : opm # # Build a catalog image.
446- $(OPM ) index add --container-tool docker --mode semver --tag $(CATALOG_IMG ) --bundles $(BUNDLE_IMG ) $(FROM_INDEX_OPT )
459+ catalog-build : opm # # Build a file-based catalog image.
460+ # Remove the catalog directory and Dockerfile
461+ -rm -r ${CATALOG_DIR} ${CATALOG_DOCKERFILE}
462+ @mkdir -p ${CATALOG_DIR}
463+ $(OPM ) generate dockerfile ${CATALOG_DIR}
464+ $(OPM ) init ${OPERATOR_NAME} \
465+ --default-channel=${CHANNELS} \
466+ --description=./README.md \
467+ --icon=${BLUE_ICON_PATH} \
468+ --output yaml \
469+ > ${CATALOG_INDEX}
470+ $(OPM ) render ${BUNDLE_IMG} --output yaml >> ${CATALOG_INDEX}
471+ $(MAKE ) add_channel_entry_for_the_bundle
472+ $(OPM ) validate ${CATALOG_DIR}
473+ docker build . -f ${CATALOG_DOCKERFILE} -t ${CATALOG_IMG}
474+ # Clean up the catalog directory and Dockerfile
475+ rm -r ${CATALOG_DIR} ${CATALOG_DOCKERFILE}
447476
448477.PHONY : catalog-push
449478catalog-push : # # Push a catalog image.
@@ -453,17 +482,17 @@ catalog-push: ## Push a catalog image.
453482
454483.PHONY : test-scorecard
455484test-scorecard : operator-sdk # # Run Scorecard testing for the bundle directory on OPERATOR_NAMESPACE
456- $(OPERATOR_SDK ) scorecard ./bundle -n $(OPERATOR_NAMESPACE )
485+ $(OPERATOR_SDK ) scorecard ./bundle -n $(OPERATOR_NAMESPACE )
457486
458- .PHONY : check
487+ .PHONY : check
459488check : # # Dockerized version of make test
460489 $(DOCKER_GO ) " make test"
461490
462491.PHONY : verify-unchanged
463492verify-unchanged : # # Verify there are no un-committed changes
464493 ./hack/verify-unchanged.sh
465494
466- .PHONY : container-build
495+ .PHONY : container-build
467496container-build : check # # Build containers
468497 $(DOCKER_GO ) " make bundle"
469498 make docker-build bundle-build
@@ -475,12 +504,12 @@ bundle-build-community: bundle-community ## Run bundle community changes in CSV,
475504.PHONY : container-build-community
476505container-build-community : docker-build bundle-build-community # # Build containers for community
477506
478- .PHONY : container-push
507+ .PHONY : container-push
479508container-push : docker-push bundle-push catalog-build catalog-push# # Push containers (NOTE: catalog can't be build before bundle was pushed)
480509
481510.PHONY : container-build-and-push-community
482511container-build-and-push-community : container-build-community container-push # # Build four images, update CSV for community, and push all the images to Quay (docker, bundle, and catalog).
483512
484- .PHONY : cluster-functest
513+ .PHONY : cluster-functest
485514cluster-functest : ginkgo # # Run e2e tests in a real cluster
486515 ./hack/functest.sh $(GINKGO_VERSION )
0 commit comments