Skip to content

Commit

Permalink
generate-versions.sh: force to build operators when an app is built
Browse files Browse the repository at this point in the history
  • Loading branch information
fredericlepied committed Jun 7, 2023
1 parent f408738 commit ff72ca0
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
28 changes: 25 additions & 3 deletions generate-versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,41 @@ DIRS="testpmd-container-app trex-container-app cnf-app-mac-operator testpmd-lb-o

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

TESTPMD_APP=false
TREX_APP=false

echo "declare -A VERSIONS" > "$VERSIONS"

count=0
for d in $DIRS; do
vers="$(cd "$d" || exit 1; make -s version)"
# Force to build the operators if the corresponding app is built
force=false
case "$d" in
testpmd-lb-operator|testpmd-operator)
if [ "$TESTPMD_APP" == true ]; then
force=true
fi
;;
trex-operator)
if [ "$TREX_APP" == true ]; then
force=true
fi
;;
esac
# Force nfv-example-cnf-index to be displayed if at least one
# change to the subdirs has been detected. This will force the
# index to be generated. TODO: force the operators to be rebuilt
# if there is a change in the apps.
if [ "$FORCE_BUILD" == true ] || grep -q "$d/" <<< "$FILES" || { [ "$d" == nfv-example-cnf-index ] && [ "$count" -gt 0 ]; }; then
# index to be generated.
if [ "$force" == true ] || [ "$FORCE_BUILD" == true ] || grep -q "$d/" <<< "$FILES" || { [ "$d" == nfv-example-cnf-index ] && [ "$count" -gt 0 ]; }; then
echo "VERSIONS[$d]=$vers-$EXTRA" >> "$VERSIONS"
echo "$d"
count=$((count + 1))
if [ "$d" == testpmd-container-app ]; then
TESTPMD_APP=true
fi
if [ "$d" == trex-container-app ]; then
TREX_APP=true
fi
else
echo "VERSIONS[$d]=$vers" >> "$VERSIONS"
fi
Expand Down
9 changes: 6 additions & 3 deletions nfv-example-cnf-index/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ clean:
# Build the index image
index-build: opm
@{ \
set -ex ;\
set -e ;\
mkdir -p $(BUILD_PATH)/$(INDEX_NAME) ;\
rm -f $(BUILD_PATH)/$(INDEX_NAME)/index.yml ;\
cp "$(INDEX_NAME).Dockerfile" $(BUILD_PATH)/ ;\
Expand All @@ -46,9 +46,12 @@ index-build: opm
bundle_digest=$(REGISTRY)/$(ORG)/$${operator_bundle}@$${operator_digest} ;\
echo "operator=$${operator_name} operator_version=$${operator_version} operator_digest=$${operator_digest}" ;\
default_channel=$$(jq -r '.Labels."operators.operatorframework.io.bundle.channel.default.v1"' <<< $${operator_manifest}) ;\
channel="---\nschema: olm.channel\npackage: $${operator_name}\nname: $${default_channel}\nentries:\n - name: $${operator_name}.$${operator_version}" ;\
$(OPM) init $${operator_name} --default-channel=$${default_channel} --output=yaml >> $(BUILD_PATH)/$(INDEX_NAME)/index.yml ;\
$(OPM) render $${bundle_digest} --output=yaml >> $(BUILD_PATH)/$(INDEX_NAME)/index.yml ;\
rendered=$$($(OPM) render $${bundle_digest} --output=yaml) ;\
echo "$${rendered}" >> $(BUILD_PATH)/$(INDEX_NAME)/index.yml ;\
operator_name_version=$$(sed -n -e 's/^name: //p'<<< "$$rendered") ;\
echo "$${operator_name_version}" ;\
channel="---\nschema: olm.channel\npackage: $${operator_name}\nname: $${default_channel}\nentries:\n - name: $${operator_name_version}" ;\
echo -e $${channel} >> $(BUILD_PATH)/$(INDEX_NAME)/index.yml ;\
done ;\
echo "validating the catalog" ;\
Expand Down

0 comments on commit ff72ca0

Please sign in to comment.