Skip to content

Commit

Permalink
Build a file-based catalog
Browse files Browse the repository at this point in the history
Signed-off-by: Carlo Lobrano <c.lobrano@gmail.com>
  • Loading branch information
clobrano committed Feb 8, 2024
1 parent d734241 commit 1a7990e
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -352,12 +352,31 @@ ifneq ($(origin CATALOG_BASE_IMG), undefined)
FROM_INDEX_OPT := --from-index $(CATALOG_BASE_IMG)
endif

# 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
# 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
.PHONY: catalog-build
catalog-build: opm ## Build a catalog image.
$(OPM) index add --container-tool docker --mode semver --tag $(CATALOG_IMG) --bundles $(BUNDLE_IMGS) $(FROM_INDEX_OPT)
@mkdir -p catalog_dir
$(OPM) generate dockerfile catalog_dir
$(OPM) init ${OPERATOR_NAME} \
--default-channel=${CHANNELS} \
--description=./README.md \
--icon=./config/assets/medik8s_blue_icon.png \
--output yaml \
> catalog_dir/index.yaml
$(OPM) render ${BUNDLE_IMG} --output yaml >> catalog_dir/index.yaml
$(MAKE) add_channel_entry_for_the_bundle
$(OPM) validate catalog_dir
docker build . -f catalog_dir.Dockerfile -t ${CATALOG_IMG} && \
rm -r catalog_dir catalog_dir.Dockerfile

add_channel_entry_for_the_bundle:
@echo "---" >> catalog_dir/index.yaml
@echo "schema: olm.channel" >> catalog_dir/index.yaml
@echo "package: ${OPERATOR_NAME}" >> catalog_dir/index.yaml
@echo "name: ${CHANNELS}" >> catalog_dir/index.yaml
@echo "entries:" >> catalog_dir/index.yaml
@echo " - name: ${OPERATOR_NAME}.v${VERSION}" >> catalog_dir/index.yaml

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

0 comments on commit 1a7990e

Please sign in to comment.