Skip to content

Commit

Permalink
fix(kfluxbugs-1142) make related image check work with yaml and json
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Cole <[email protected]>
  • Loading branch information
14rcole committed Jun 27, 2024
1 parent a2d8591 commit da60488
Showing 1 changed file with 6 additions and 11 deletions.
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

0 comments on commit da60488

Please sign in to comment.