Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(kfluxbugs-1142) make related image check work with yaml and json #1088

Merged
merged 1 commit into from
Jun 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions task/fbc-related-image-check/0.1/fbc-related-image-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,20 @@ spec:
trap 'handle_error $(results.TEST_OUTPUT.path)' EXIT

FAILEDIMAGES=""
catalog="$(find $(workspaces.workspace.path)/hacbs/fbc-validation/ -name catalog.yaml)"
catalog="$(opm render $(workspaces.workspace.path)/hacbs/fbc-validation/confdir/)"

# OPM generates catalog file in a way that yaml file could contain stream of JSON objects
# thats why we need jq in for this situation, because yq can't parse this file
# however there is also posibility that catalog.yaml has yaml data in it

status=0
relImgs="$(yq -r '.relatedImages[]?.image' $catalog)" || status=$?
relImgs="$(jq -r '.relatedImages[]?.image' <<< ${catalog)" || status=$?
if [ $status -ne 0 ]; then
echo "Processing the catalog with yq failed because catalog.yaml contains data type other than yaml. Attempting to process with jq..."
status=0
relImgs="$(jq -r '.relatedImages[]?.image' $catalog)" || status=$?
if [ $status -ne 0 ]; then
echo "Could not get related images. Make sure catalog.yaml exists in FBC fragment image and it is valid .yaml format."
note="Task $(context.task.name) failed: Could not fetch related images. Make sure you have catalog.yaml formatted correctly in your file-based catalog (FBC) fragment image."
TEST_OUTPUT=$(make_result_json -r FAILURE -f 1 -t "$note")
echo "${TEST_OUTPUT}" | tee "$(results.TEST_OUTPUT.path)"
echo "Could not get related images. Make sure catalog.yaml exists in FBC fragment image and it is valid .yaml or .json format."
note="Task $(context.task.name) failed: Could not fetch related images. Make sure you have catalog.yaml or catalog.json formatted correctly in your file-based catalog (FBC) fragment image."
TEST_OUTPUT=$(make_result_json -r FAILURE -f 1 -t "$note")
echo "${TEST_OUTPUT}" | tee "$(results.TEST_OUTPUT.path)"
exit 0
fi
fi

echo -e "These are related images:\n$relImgs."
Expand Down
Loading