diff --git a/Makefile b/Makefile index cac86f4d..f9f873e1 100644 --- a/Makefile +++ b/Makefile @@ -406,17 +406,40 @@ endef build-tools: ## Download & build all the tools locally if necessary. $(MAKE) kustomize controller-gen envtest goimports sort-imports ginkgo opm operator-sdk -# Set CATALOG_BASE_IMG to an existing catalog image tag to add $BUNDLE_IMGS to that image. -ifneq ($(origin CATALOG_BASE_IMG), undefined) -FROM_INDEX_OPT := --from-index $(CATALOG_BASE_IMG) -endif +# Build a file-based catalog image +# https://docs.openshift.com/container-platform/4.14/operators/admin/olm-managing-custom-catalogs.html#olm-managing-custom-catalogs-fb +# NOTE: CATALOG_DIR and CATALOG_DOCKERFILE items won't be deleted in case of recipe's failure +CATALOG_DIR := catalog +CATALOG_DOCKERFILE := ${CATALOG_DIR}.Dockerfile +CATALOG_INDEX := $(CATALOG_DIR)/index.yaml + +.PHONY: add_channel_entry_for_the_bundle +add_channel_entry_for_the_bundle: + @echo "---" >> ${CATALOG_INDEX} + @echo "schema: olm.channel" >> ${CATALOG_INDEX} + @echo "package: ${OPERATOR_NAME}" >> ${CATALOG_INDEX} + @echo "name: ${CHANNELS}" >> ${CATALOG_INDEX} + @echo "entries:" >> ${CATALOG_INDEX} + @echo " - name: ${OPERATOR_NAME}.v${VERSION}" >> ${CATALOG_INDEX} -# Build a catalog image by adding bundle images to an empty catalog using the operator package manager tool, 'opm'. -# This recipe invokes 'opm' in 'semver' bundle add mode. For more information on add modes, see: -# https://github.com/operator-framework/community-operators/blob/7f1438c/docs/packaging-operator.md#updating-your-existing-operator .PHONY: catalog-build -catalog-build: opm ## Build a catalog image. - $(OPM) index add --container-tool docker --mode semver --tag $(CATALOG_IMG) --bundles $(BUNDLE_IMG) $(FROM_INDEX_OPT) +catalog-build: opm ## Build a file-based catalog image. + # Remove the catalog directory and Dockerfile + -rm -r ${CATALOG_DIR} ${CATALOG_DOCKERFILE} + @mkdir -p ${CATALOG_DIR} + $(OPM) generate dockerfile ${CATALOG_DIR} + $(OPM) init ${OPERATOR_NAME} \ + --default-channel=${CHANNELS} \ + --description=./README.md \ + --icon=${BLUE_ICON_PATH} \ + --output yaml \ + > ${CATALOG_INDEX} + $(OPM) render ${BUNDLE_IMG} --output yaml >> ${CATALOG_INDEX} + $(MAKE) add_channel_entry_for_the_bundle + $(OPM) validate ${CATALOG_DIR} + docker build . -f ${CATALOG_DOCKERFILE} -t ${CATALOG_IMG} + # Clean up the catalog directory and Dockerfile + rm -r ${CATALOG_DIR} ${CATALOG_DOCKERFILE} # Push the catalog image. .PHONY: catalog-push