-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
File-based OLM catalog with history (#1308)
Signed-off-by: Michael Edgar <[email protected]>
- Loading branch information
Showing
17 changed files
with
214 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,39 @@ | ||
#!/bin/bash | ||
|
||
set -xEeuo pipefail | ||
|
||
SCRIPT_PATH="$(cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P)" | ||
|
||
export VERSION="${1}" | ||
export CONSOLE_OPERATOR_BUNDLE="${1:-}" | ||
export USE_HTTP="${2:-false}" | ||
|
||
source ${SCRIPT_PATH}/common.sh | ||
OPERATOR_PATH="$(cd -- "${SCRIPT_PATH}/.." >/dev/null 2>&1 ; pwd -P)" | ||
CATALOG_PATH=${OPERATOR_PATH}/target/catalog | ||
|
||
echo "[INFO] Generate catalog" | ||
|
||
rm -rvf ${CATALOG_PATH} ${CATALOG_PATH}.Dockerfile | ||
echo "[INFO] Generate catalog in ${CATALOG_PATH}" | ||
rm -rvf ${CATALOG_PATH} | ||
mkdir -p ${CATALOG_PATH} | ||
cp -v ${OPERATOR_PATH}/src/main/olm/*.yaml ${CATALOG_PATH}/ | ||
|
||
for CSV_NAME in $(${YQ} '.entries[].name' ${CATALOG_PATH}/channel.alpha.yaml | sort -V) ; do | ||
if [ -f ${OPERATOR_PATH}/src/main/olm/bundles/${CSV_NAME}.yaml ] ; then | ||
BUNDLE_IMAGE=$(${YQ} '.image' ${OPERATOR_PATH}/src/main/olm/bundles/${CSV_NAME}.yaml) | ||
elif [ -d ${CONSOLE_OPERATOR_BUNDLE} ] ; then | ||
BUNDLE_IMAGE=${CONSOLE_OPERATOR_BUNDLE} | ||
else | ||
BUNDLE_IMAGE=${CONSOLE_OPERATOR_BUNDLE}:$(echo "${CSV_NAME}" | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+(-snapshot)?$') | ||
fi | ||
|
||
opm generate dockerfile ${CATALOG_PATH} | ||
opm init ${OPERATOR_NAME} --default-channel=alpha --output=yaml > ${OPERATOR_CATALOG_CONFIG_YAML_PATH} | ||
opm render ${BUNDLE_PATH} --output=yaml >> ${OPERATOR_CATALOG_CONFIG_YAML_PATH} | ||
RENDER_FLAGS='--output=yaml' | ||
|
||
cat << EOF >> ${OPERATOR_CATALOG_CONFIG_YAML_PATH} | ||
--- | ||
schema: olm.channel | ||
package: ${OPERATOR_NAME} | ||
name: alpha | ||
entries: | ||
- name: ${OPERATOR_CSV_NAME} | ||
EOF | ||
if [ "${USE_HTTP}" == "true" ] ; then | ||
RENDER_FLAGS="--use-http ${RENDER_FLAGS}" | ||
fi | ||
|
||
# Rename package names | ||
${YQ} eval -o yaml -i ". |= select(.package == \"${ORIGINAL_OPERATOR_NAME}\").package = \"${OPERATOR_NAME}\"" "${OPERATOR_CATALOG_CONFIG_YAML_PATH}" | ||
${YQ} eval -o yaml -i "(.properties[] | select(.value.packageName == \"${ORIGINAL_OPERATOR_NAME}\") | .value.packageName) = \"${OPERATOR_NAME}\"" "${OPERATOR_CATALOG_CONFIG_YAML_PATH}" | ||
opm render ${BUNDLE_IMAGE} ${RENDER_FLAGS} > ${CATALOG_PATH}/${CSV_NAME}.yaml | ||
done | ||
|
||
opm validate ${CATALOG_PATH} | ||
|
||
echo "[DEBUG] Catalog generated" | ||
echo "[DEBUG] Catalog generated" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/bin/bash | ||
|
||
set -xEeuo pipefail | ||
|
||
SCRIPT_PATH="$(cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P)" | ||
OPERATOR_PATH="$(cd -- "${SCRIPT_PATH}/.." >/dev/null 2>&1 ; pwd -P)" | ||
|
||
PRERELEASE_VERSION="${1?prerelease version is required}" | ||
RELEASE_VERSION="${2?release version is required}" | ||
POSTRELEASE_VERSION="${3?postrelease version is required}" | ||
VERSION="${4?current version is required}" | ||
IMAGE_NAME="${5?image name is required}" | ||
GIT_STAGE="${6:-false}" | ||
|
||
source ${SCRIPT_PATH}/common.sh | ||
|
||
PRERELEASE_CSV_NAME="${OPERATOR_NAME}.v${PRERELEASE_VERSION}" | ||
RELEASE_CSV_NAME="${OPERATOR_NAME}.v${RELEASE_VERSION}" | ||
POSTRELEASE_CSV_NAME="${OPERATOR_NAME}.v${POSTRELEASE_VERSION}" | ||
|
||
if [ "${VERSION}" == "${POSTRELEASE_VERSION}" ] ; then | ||
# Running via the `completionGoals` of the maven-release-plugin | ||
echo "[INFO] Running release completion with version ${VERSION}" | ||
|
||
# Create new entry for the next development cycle, "replaces" the version just released | ||
${YQ} -i '.entries += { | ||
"name": "'${POSTRELEASE_CSV_NAME}'", | ||
"replaces": "'${RELEASE_CSV_NAME}'" | ||
}' ${OPERATOR_PATH}/src/main/olm/channel.alpha.yaml | ||
|
||
if [ "${GIT_STAGE}" == "true" ] ; then | ||
git add ${OPERATOR_PATH}/src/main/olm/channel.alpha.yaml | ||
fi | ||
else | ||
# Running via the `preparationGoals` of the maven-release-plugin | ||
echo "[INFO] Running release preparation for version ${VERSION}" | ||
|
||
# Change the name of the entry to be the released version (e.g removing the -snapshot suffix) | ||
${YQ} -i '(.entries[].name | select(. == "'${PRERELEASE_CSV_NAME}'")) = "'${RELEASE_CSV_NAME}'"' \ | ||
${OPERATOR_PATH}/src/main/olm/channel.alpha.yaml | ||
|
||
# Create a file with a reference to the bundle image to be generated during the release | ||
echo "image: ${IMAGE_NAME}:${VERSION}" > ${OPERATOR_PATH}/src/main/olm/bundles/${RELEASE_CSV_NAME}.yaml | ||
|
||
if [ "${GIT_STAGE}" == "true" ] ; then | ||
git add ${OPERATOR_PATH}/src/main/olm/channel.alpha.yaml ${OPERATOR_PATH}/src/main/olm/bundles/${RELEASE_CSV_NAME}.yaml | ||
fi | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
|
||
set -xEeuo pipefail | ||
|
||
SCRIPT_PATH="$(cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P)" | ||
OPERATOR_PATH="$(cd -- "${SCRIPT_PATH}/.." >/dev/null 2>&1 ; pwd -P)" | ||
|
||
VERSION="${1?version is required}" | ||
|
||
source ${SCRIPT_PATH}/common.sh | ||
OPERATOR_CSV_NAME="${OPERATOR_NAME}.v${VERSION}" | ||
ALPHA_CHANNEL=${OPERATOR_PATH}/src/main/olm/channel.alpha.yaml | ||
|
||
if [ "$(${YQ} '(.entries[].name | select(. == "'${OPERATOR_CSV_NAME}'"))' ${ALPHA_CHANNEL})" != "" ] ; then | ||
echo "[INFO] Bundle ${OPERATOR_CSV_NAME} has an entry in ${ALPHA_CHANNEL}" | ||
exit 0; | ||
fi | ||
|
||
echo "[ERROR] Bundle ${OPERATOR_CSV_NAME} has no entry in ${ALPHA_CHANNEL}" | ||
exit 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.