Skip to content

Commit

Permalink
Merge pull request #252 from Shai1-Levi/bugfix/ep-2583
Browse files Browse the repository at this point in the history
Build file based catalog
  • Loading branch information
openshift-merge-bot[bot] authored Jan 30, 2025
2 parents 2cc3c1b + 894f786 commit 7822739
Showing 1 changed file with 36 additions and 6 deletions.
42 changes: 36 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ YQ_VERSION = v4.44.1
OPERATOR_NAME ?= self-node-remediation
OPERATOR_NAMESPACE ?= openshift-workload-availability

BLUE_ICON_PATH = "./config/assets/snr_icon_blue.png"

# VERSION defines the project version for the bundle.
# Update this value when you upgrade the version of your project.
# To re-generate a bundle for another specific version without changing the standard setup, you can:
Expand Down Expand Up @@ -313,7 +315,7 @@ rm -rf $$TMP_DIR ;\
}
endef

DEFAULT_ICON_BASE64 := $(shell base64 --wrap=0 ./config/assets/snr_icon_blue.png)
DEFAULT_ICON_BASE64 := $(shell base64 --wrap=0 ${BLUE_ICON_PATH})
export ICON_BASE64 ?= ${DEFAULT_ICON_BASE64}
export CSV ?= "./bundle/manifests/$(OPERATOR_NAME).clusterserviceversion.yaml"
.PHONY: bundle
Expand Down Expand Up @@ -455,15 +457,43 @@ ifeq (,$(wildcard $(OPM)))
endif

# Set CATALOG_BASE_IMG to an existing catalog image tag to add $BUNDLE_IMG 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}

.PHONY: catalog-push
catalog-push: ## Push a catalog image.
Expand Down

0 comments on commit 7822739

Please sign in to comment.