Skip to content

Commit

Permalink
Add dns-operator to catalog build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
mikenairn committed Feb 15, 2024
1 parent c3e429d commit cc28fdd
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
6 changes: 6 additions & 0 deletions catalog/dns-operator-channel-entry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
schema: olm.channel
package: dns-operator
name: preview
entries:
- name: dns-operator.v0.0.0
3 changes: 2 additions & 1 deletion make/catalog.mk
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ $(CATALOG_FILE): $(OPM) $(YQ)
@echo REPLACES_VERSION = $(REPLACES_VERSION)
@echo LIMITADOR_OPERATOR_BUNDLE_IMG = $(LIMITADOR_OPERATOR_BUNDLE_IMG)
@echo AUTHORINO_OPERATOR_BUNDLE_IMG = $(AUTHORINO_OPERATOR_BUNDLE_IMG)
@echo DNS_OPERATOR_BUNDLE_IMG = $(DNS_OPERATOR_BUNDLE_IMG)
@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) $(REPLACES_VERSION)\
$(LIMITADOR_OPERATOR_BUNDLE_IMG) $(AUTHORINO_OPERATOR_BUNDLE_IMG) $(CHANNELS) $@
$(LIMITADOR_OPERATOR_BUNDLE_IMG) $(AUTHORINO_OPERATOR_BUNDLE_IMG) $(DNS_OPERATOR_BUNDLE_IMG) $(CHANNELS) $@

.PHONY: catalog
catalog: $(OPM) ## Generate catalog content and validate.
Expand Down
30 changes: 26 additions & 4 deletions utils/generate-catalog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ BUNDLE_IMG="${3?:Error \$BUNDLE_IMG not set. Bye}"
REPLACES_VERSION="${4?:Error \$REPLACES_VERSION not set. Bye}"
LIMITADOR_OPERATOR_BUNDLE_IMG="${5?:Error \$LIMITADOR_OPERATOR_BUNDLE_IMG not set. Bye}"
AUTHORINO_OPERATOR_BUNDLE_IMG="${6?:Error \$AUTHORINO_OPERATOR_BUNDLE_IMG not set. Bye}"
CHANNELS="${7:-$DEFAULT_CHANNEL}"
CATALOG_FILE="${8?:Error \$CATALOG_FILE not set. Bye}"
DNS_OPERATOR_BUNDLE_IMG="${7?:Error \$DNS_OPERATOR_BUNDLE_IMG not set. Bye}"
CHANNELS="${8:-$DEFAULT_CHANNEL}"
CATALOG_FILE="${9?:Error \$CATALOG_FILE not set. Bye}"

CATALOG_FILE_BASEDIR="$( cd "$( dirname "$(realpath ${CATALOG_FILE})" )" && pwd )"
CATALOG_BASEDIR="$( cd "$( dirname "$(realpath ${CATALOG_FILE_BASEDIR})" )" && pwd )"
Expand All @@ -26,13 +27,16 @@ TMP_DIR=$(mktemp -d)
${OPM} render ${BUNDLE_IMG} --output=yaml >> ${TMP_DIR}/kuadrant-operator-bundle.yaml
${OPM} render ${LIMITADOR_OPERATOR_BUNDLE_IMG} --output=yaml >> ${TMP_DIR}/limitador-operator-bundle.yaml
${OPM} render ${AUTHORINO_OPERATOR_BUNDLE_IMG} --output=yaml >> ${TMP_DIR}/authorino-operator-bundle.yaml
${OPM} render ${DNS_OPERATOR_BUNDLE_IMG} --output=yaml >> ${TMP_DIR}/dns-operator-bundle.yaml

# Verify kuadrant operator bundle's limitador/authorino references are the same
# as provided by LIMITADOR_OPERATOR_BUNDLE_IMG and AUTHORINO_OPERATOR_BUNDLE_IMG
# Verify kuadrant operator bundle's limitador/authorino/dns references are the same
# as provided by LIMITADOR_OPERATOR_BUNDLE_IMG; AUTHORINO_OPERATOR_BUNDLE_IMG and DNS_OPERATOR_BUNDLE_IMG
LIMITADOR_VERSION=`${YQ} eval '.properties[] | select(.type == "olm.package") | .value.version' ${TMP_DIR}/limitador-operator-bundle.yaml`
AUTHORINO_VERSION=`${YQ} eval '.properties[] | select(.type == "olm.package") | .value.version' ${TMP_DIR}/authorino-operator-bundle.yaml`
DNS_VERSION=`${YQ} eval '.properties[] | select(.type == "olm.package") | .value.version' ${TMP_DIR}/dns-operator-bundle.yaml`
LIMITADOR_REFERENCED_VERSION=`${YQ} eval '.properties[] | select(.type == "olm.package.required") | select(.value.packageName == "limitador-operator").value.versionRange' ${TMP_DIR}/kuadrant-operator-bundle.yaml`
AUTHORINO_REFERENCED_VERSION=`${YQ} eval '.properties[] | select(.type == "olm.package.required") | select(.value.packageName == "authorino-operator").value.versionRange' ${TMP_DIR}/kuadrant-operator-bundle.yaml`
DNS_REFERENCED_VERSION=`${YQ} eval '.properties[] | select(.type == "olm.package.required") | select(.value.packageName == "dns-operator").value.versionRange' ${TMP_DIR}/kuadrant-operator-bundle.yaml`

if [[ "${LIMITADOR_VERSION}" != "${LIMITADOR_REFERENCED_VERSION}" ]]
then
Expand All @@ -46,6 +50,12 @@ then
exit 1
fi

if [[ "${DNS_VERSION}" != "${DNS_REFERENCED_VERSION}" ]]
then
echo -e "\033[31mReferenced DNS version is ${DNS_REFERENCED_VERSION}, but found ${DNS_VERSION} in the bundle \033[0m" >/dev/stderr
exit 1
fi

mkdir -p ${CATALOG_FILE_BASEDIR}
touch ${CATALOG_FILE}

Expand Down Expand Up @@ -73,6 +83,18 @@ V=`${YQ} eval '.name' ${TMP_DIR}/authorino-operator-bundle.yaml` \
CHANNELS=${CHANNELS} \
${YQ} eval '(.entries[0].name = strenv(V)) | (.name = strenv(CHANNELS))' ${CATALOG_BASEDIR}/authorino-operator-channel-entry.yaml >> ${CATALOG_FILE}

###
# DNS Operator
###
# Add the package
${OPM} init dns-operator --default-channel=${CHANNELS} --output yaml >> ${CATALOG_FILE}
# Add a bundles to the Catalog
cat ${TMP_DIR}/dns-operator-bundle.yaml >> ${CATALOG_FILE}
# Add a channel entry for the bundle
V=`${YQ} eval '.name' ${TMP_DIR}/dns-operator-bundle.yaml` \
CHANNELS=${CHANNELS} \
${YQ} eval '(.entries[0].name = strenv(V)) | (.name = strenv(CHANNELS))' ${CATALOG_BASEDIR}/dns-operator-channel-entry.yaml >> ${CATALOG_FILE}

###
# Kuadrant Operator
###
Expand Down

0 comments on commit cc28fdd

Please sign in to comment.