Skip to content

Commit ff72ca0

Browse files
generate-versions.sh: force to build operators when an app is built
1 parent f408738 commit ff72ca0

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

generate-versions.sh

+25-3
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,41 @@ DIRS="testpmd-container-app trex-container-app cnf-app-mac-operator testpmd-lb-o
1414

1515
FILES="$(git diff --name-only -r origin/${GITHUB_BASE_REF:-main}:)"
1616

17+
TESTPMD_APP=false
18+
TREX_APP=false
19+
1720
echo "declare -A VERSIONS" > "$VERSIONS"
1821

1922
count=0
2023
for d in $DIRS; do
2124
vers="$(cd "$d" || exit 1; make -s version)"
25+
# Force to build the operators if the corresponding app is built
26+
force=false
27+
case "$d" in
28+
testpmd-lb-operator|testpmd-operator)
29+
if [ "$TESTPMD_APP" == true ]; then
30+
force=true
31+
fi
32+
;;
33+
trex-operator)
34+
if [ "$TREX_APP" == true ]; then
35+
force=true
36+
fi
37+
;;
38+
esac
2239
# Force nfv-example-cnf-index to be displayed if at least one
2340
# change to the subdirs has been detected. This will force the
24-
# index to be generated. TODO: force the operators to be rebuilt
25-
# if there is a change in the apps.
26-
if [ "$FORCE_BUILD" == true ] || grep -q "$d/" <<< "$FILES" || { [ "$d" == nfv-example-cnf-index ] && [ "$count" -gt 0 ]; }; then
41+
# index to be generated.
42+
if [ "$force" == true ] || [ "$FORCE_BUILD" == true ] || grep -q "$d/" <<< "$FILES" || { [ "$d" == nfv-example-cnf-index ] && [ "$count" -gt 0 ]; }; then
2743
echo "VERSIONS[$d]=$vers-$EXTRA" >> "$VERSIONS"
2844
echo "$d"
2945
count=$((count + 1))
46+
if [ "$d" == testpmd-container-app ]; then
47+
TESTPMD_APP=true
48+
fi
49+
if [ "$d" == trex-container-app ]; then
50+
TREX_APP=true
51+
fi
3052
else
3153
echo "VERSIONS[$d]=$vers" >> "$VERSIONS"
3254
fi

nfv-example-cnf-index/Makefile

+6-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ clean:
3030
# Build the index image
3131
index-build: opm
3232
@{ \
33-
set -ex ;\
33+
set -e ;\
3434
mkdir -p $(BUILD_PATH)/$(INDEX_NAME) ;\
3535
rm -f $(BUILD_PATH)/$(INDEX_NAME)/index.yml ;\
3636
cp "$(INDEX_NAME).Dockerfile" $(BUILD_PATH)/ ;\
@@ -46,9 +46,12 @@ index-build: opm
4646
bundle_digest=$(REGISTRY)/$(ORG)/$${operator_bundle}@$${operator_digest} ;\
4747
echo "operator=$${operator_name} operator_version=$${operator_version} operator_digest=$${operator_digest}" ;\
4848
default_channel=$$(jq -r '.Labels."operators.operatorframework.io.bundle.channel.default.v1"' <<< $${operator_manifest}) ;\
49-
channel="---\nschema: olm.channel\npackage: $${operator_name}\nname: $${default_channel}\nentries:\n - name: $${operator_name}.$${operator_version}" ;\
5049
$(OPM) init $${operator_name} --default-channel=$${default_channel} --output=yaml >> $(BUILD_PATH)/$(INDEX_NAME)/index.yml ;\
51-
$(OPM) render $${bundle_digest} --output=yaml >> $(BUILD_PATH)/$(INDEX_NAME)/index.yml ;\
50+
rendered=$$($(OPM) render $${bundle_digest} --output=yaml) ;\
51+
echo "$${rendered}" >> $(BUILD_PATH)/$(INDEX_NAME)/index.yml ;\
52+
operator_name_version=$$(sed -n -e 's/^name: //p'<<< "$$rendered") ;\
53+
echo "$${operator_name_version}" ;\
54+
channel="---\nschema: olm.channel\npackage: $${operator_name}\nname: $${default_channel}\nentries:\n - name: $${operator_name_version}" ;\
5255
echo -e $${channel} >> $(BUILD_PATH)/$(INDEX_NAME)/index.yml ;\
5356
done ;\
5457
echo "validating the catalog" ;\

0 commit comments

Comments
 (0)