Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build a file-based catalog #138

Merged
merged 2 commits into from
Apr 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 32 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -405,17 +405,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
Expand Down
Loading