From ba5a49dd463bd32497eed9060190f74b5565a983 Mon Sep 17 00:00:00 2001 From: dd di cesare Date: Wed, 27 Sep 2023 11:46:27 +0200 Subject: [PATCH] [catalog] Adding the `replaces` directive to the generated catalog --- make/catalog.mk | 7 ++++--- utils/generate-catalog.sh | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/make/catalog.mk b/make/catalog.mk index a25f7183..413148e8 100644 --- a/make/catalog.mk +++ b/make/catalog.mk @@ -15,13 +15,14 @@ $(CATALOG_FILE): $(OPM) $(YQ) @echo "************************************************************" @echo Build limitador operator catalog @echo - @echo BUNDLE_IMG = $(BUNDLE_IMG) - @echo CHANNELS = $(CHANNELS) + @echo BUNDLE_IMG = $(BUNDLE_IMG) + @echo REPLACES = $(REPLACES) + @echo CHANNELS = $(CHANNELS) @echo "************************************************************" @echo @echo Please check this matches your expectations and override variables if needed. @echo - $(PROJECT_PATH)/utils/generate-catalog.sh $(OPM) $(YQ) $(BUNDLE_IMG) $(CHANNELS) $@ + $(PROJECT_PATH)/utils/generate-catalog.sh $(OPM) $(YQ) $(BUNDLE_IMG) $(REPLACES) $(CHANNELS) $@ .PHONY: catalog catalog: $(OPM) ## Generate catalog content and validate. diff --git a/utils/generate-catalog.sh b/utils/generate-catalog.sh index 19938429..ec0bc974 100755 --- a/utils/generate-catalog.sh +++ b/utils/generate-catalog.sh @@ -12,6 +12,7 @@ DEFAULT_CHANNEL=preview OPM="${1?:Error \$OPM not set. Bye}" YQ="${2?:Error \$YQ not set. Bye}" BUNDLE_IMG="${3?:Error \$BUNDLE_IMG not set. Bye}" +REPLACES="${3?:Error \$REPLACES not set. Bye}" CHANNELS="${4:-$DEFAULT_CHANNEL}" CATALOG_FILE="${5?:Error \$CATALOG_FILE not set. Bye}" @@ -34,7 +35,8 @@ ${OPM} init limitador-operator --default-channel=${CHANNELS} --output yaml >> ${ cat ${TMP_DIR}/limitador-operator-bundle.yaml >> ${CATALOG_FILE} # Add a channel entry for the bundle V=`${YQ} eval '.name' ${TMP_DIR}/limitador-operator-bundle.yaml` \ +REPLACES=limitador-operator.v${REPLACES_VERSION} \ CHANNELS=${CHANNELS} \ - ${YQ} eval '(.entries[0].name = strenv(V)) | (.name = strenv(CHANNELS))' ${CATALOG_BASEDIR}/limitador-operator-channel-entry.yaml >> ${CATALOG_FILE} + ${YQ} eval '(.entries[0].name = strenv(V)) | (.entries[0].replaces = strenv(REPLACES)) | (.name = strenv(CHANNELS))' ${CATALOG_BASEDIR}/limitador-operator-channel-entry.yaml >> ${CATALOG_FILE} rm -rf $TMP_DIR