|
1 | 1 | DOCKER_REPO=$1
|
2 | 2 | OPERATOR_NAME=$2
|
3 | 3 | CATALOG_DIR_PATH=$3
|
| 4 | +VERSION=$4 |
| 5 | +PR_TAG=$5 |
4 | 6 |
|
5 | 7 | # Get entries and iterate
|
6 |
| -CHANNEL_BUNDLES=$(yq eval-all 'select(.schema == "olm.channel") | .entries[].name' $CATALOG_DIR_PATH/channels.yaml | grep -v '^---$' | sort | uniq) |
| 8 | +CHANNEL_BUNDLES=$(yq eval-all 'select(.schema == "olm.channel") | .entries[].name' "$CATALOG_DIR_PATH"/channels.yaml | grep -v '^---$' | sort | uniq) |
7 | 9 | # Render all required bundles
|
8 |
| -rm -rf $CATALOG_DIR_PATH/bundles.yaml |
| 10 | +rm -rf "$CATALOG_DIR_PATH"/bundles.yaml |
| 11 | + |
9 | 12 | echo " catalog build start"
|
| 13 | +SHOULD_RELEASE="false" |
10 | 14 | for item in $CHANNEL_BUNDLES; do
|
11 |
| - bundle="${item//${OPERATOR_NAME}./${OPERATOR_NAME}-bundle:}" |
12 |
| - opm render "$DOCKER_REPO/$bundle" --output=yaml >> $CATALOG_DIR_PATH/bundles.yaml |
| 15 | + # Setup bundle from entries |
| 16 | + if [ -n "$PR_TAG" ]; then |
| 17 | + bundle="${item//${OPERATOR_NAME}./${OPERATOR_NAME}-bundle:}-${PR_TAG}" |
| 18 | + release="${OPERATOR_NAME}-bundle:v${VERSION}-${PR_TAG}" |
| 19 | + else |
| 20 | + bundle="${item//${OPERATOR_NAME}./${OPERATOR_NAME}-bundle:}" |
| 21 | + release="${OPERATOR_NAME}-bundle:v${VERSION}" |
| 22 | + fi |
| 23 | + |
| 24 | + # Check if next release is defined in any channel |
| 25 | + if [ "${bundle}" == "${release}" ]; then |
| 26 | + SHOULD_RELEASE="true" |
| 27 | + else |
| 28 | + SHOULD_RELEASE="false" |
| 29 | + fi |
| 30 | + |
| 31 | + opm render "$DOCKER_REPO/$bundle" --output=yaml >> "$CATALOG_DIR_PATH"/bundles.yaml |
13 | 32 | echo " >> rendered $bundle >> $CATALOG_DIR_PATH/bundles.yaml"
|
14 | 33 | done
|
15 | 34 |
|
16 |
| -# Build catalog index |
17 |
| -yq eval-all '.' $CATALOG_DIR_PATH/package.yaml $CATALOG_DIR_PATH/channels.yaml $CATALOG_DIR_PATH/bundles.yaml > $CATALOG_DIR_PATH/release/index.yaml |
18 |
| -echo " >> created index >> $CATALOG_DIR_PATH/release/index.yaml" |
| 35 | +# Build catalog index if there should be a release |
| 36 | + if [ ${SHOULD_RELEASE} = "true" ]; then |
| 37 | + yq eval-all '.' "$CATALOG_DIR_PATH"/package.yaml "$CATALOG_DIR_PATH"/channels.yaml "$CATALOG_DIR_PATH"/bundles.yaml > "$CATALOG_DIR_PATH"/release/index.yaml |
| 38 | + echo " >> created index >> $CATALOG_DIR_PATH/release/index.yaml" |
| 39 | + else |
| 40 | + echo " >> release is not defined in ${CATALOG_DIR_PATH}/channels.yaml, will not create catalog index" |
| 41 | + fi |
19 | 42 |
|
20 |
| -rm -rf $CATALOG_DIR_PATH/bundles.yaml |
| 43 | +rm -rf "$CATALOG_DIR_PATH"/bundles.yaml |
21 | 44 | echo " catalog build done!"
|
22 | 45 |
|
23 | 46 | ## Delete entries
|
|
0 commit comments