Skip to content

Commit 131fb9d

Browse files
committed
Update scripts
1 parent a4a4d26 commit 131fb9d

File tree

2 files changed

+32
-9
lines changed

2 files changed

+32
-9
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ endif
337337
# Render bundle to the catalog index.
338338
.PHONY: catalog-render
339339
catalog-render: opm yq ## Render bundle to catalog index.
340-
sh generate-catalog-index.sh $(DOCKER_REPO_BASE) $(OPERATOR_NAME) $(CATALOG_DIR_PATH)
340+
sh generate-catalog-index.sh $(DOCKER_REPO_BASE) $(OPERATOR_NAME) $(CATALOG_DIR_PATH) $(VERSION) $(PR_TAG)
341341
.PHONY: catalog-build
342342
catalog-build: opm ## Build a catalog image.
343343
$(CONTAINER_TOOL) build -f catalog.Dockerfile -t $(CATALOG_IMG) .

generate-catalog-index.sh

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,46 @@
11
DOCKER_REPO=$1
22
OPERATOR_NAME=$2
33
CATALOG_DIR_PATH=$3
4+
VERSION=$4
5+
PR_TAG=$5
46

57
# 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)
79
# Render all required bundles
8-
rm -rf $CATALOG_DIR_PATH/bundles.yaml
10+
rm -rf "$CATALOG_DIR_PATH"/bundles.yaml
11+
912
echo " catalog build start"
13+
SHOULD_RELEASE="false"
1014
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
1332
echo " >> rendered $bundle >> $CATALOG_DIR_PATH/bundles.yaml"
1433
done
1534

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
1942

20-
rm -rf $CATALOG_DIR_PATH/bundles.yaml
43+
rm -rf "$CATALOG_DIR_PATH"/bundles.yaml
2144
echo " catalog build done!"
2245

2346
## Delete entries

0 commit comments

Comments
 (0)