From 34b9700febd06de51d139bfcc7443ba12f8002aa Mon Sep 17 00:00:00 2001 From: Ryan Cole Date: Tue, 18 Jun 2024 09:54:25 -0400 Subject: [PATCH] fix(kfluxbugs-1142) make related image check work with yaml and json Signed-off-by: Ryan Cole --- .../0.1/fbc-related-image-check.yaml | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/task/fbc-related-image-check/0.1/fbc-related-image-check.yaml b/task/fbc-related-image-check/0.1/fbc-related-image-check.yaml index 697f98c6db..f3360acfc6 100644 --- a/task/fbc-related-image-check/0.1/fbc-related-image-check.yaml +++ b/task/fbc-related-image-check/0.1/fbc-related-image-check.yaml @@ -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 configs/)" # 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."