From b70b591277d7f8232cd491fe00db606a10e0db39 Mon Sep 17 00:00:00 2001 From: Tomas Man Date: Fri, 20 Dec 2024 14:28:13 +0100 Subject: [PATCH] [ISV-5440] Extend relatedImages error message handling --- .../openshift/pipelines/operator-hosted-pipeline.yml | 2 ++ .../templates/openshift/tasks/digest-pinning.yml | 12 ++++++++---- .../openshift/tasks/verify-pinned-digest.yml | 3 ++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ansible/roles/operator-pipeline/templates/openshift/pipelines/operator-hosted-pipeline.yml b/ansible/roles/operator-pipeline/templates/openshift/pipelines/operator-hosted-pipeline.yml index af123e566..9c35f167c 100644 --- a/ansible/roles/operator-pipeline/templates/openshift/pipelines/operator-hosted-pipeline.yml +++ b/ansible/roles/operator-pipeline/templates/openshift/pipelines/operator-hosted-pipeline.yml @@ -763,6 +763,8 @@ spec: value: "$(tasks.digest-pinning.results.dirty_flag)" - name: related_images_flag value: "$(tasks.digest-pinning.results.related_images_flag)" + - name: related_images_message + value: "$(tasks.digest-pinning.results.related_images_message)" # Build images- bundle and index and push them to registry. # Those steps are also a part of the CI pipeline. diff --git a/ansible/roles/operator-pipeline/templates/openshift/tasks/digest-pinning.yml b/ansible/roles/operator-pipeline/templates/openshift/tasks/digest-pinning.yml index d1480e483..c8bfb3799 100644 --- a/ansible/roles/operator-pipeline/templates/openshift/tasks/digest-pinning.yml +++ b/ansible/roles/operator-pipeline/templates/openshift/tasks/digest-pinning.yml @@ -15,6 +15,7 @@ spec: results: - name: dirty_flag - name: related_images_flag + - name: related_images_message workspaces: - name: source - name: registry-credentials @@ -117,13 +118,13 @@ spec: set -xe if [ -z "$(params.bundle_path)" ]; then - echo "No bundle added or changed" + echo -n "No bundle added or changed" | tee $(results.related_images_message.path) echo -n "true" | tee $(results.related_images_flag.path) exit 0 fi if [ "$(params.enabled)" != "true" ]; then - echo "Digest pinning is not enabled" + echo -n "Digest pinning is not enabled" | tee $(results.related_images_message.path) echo -n "true" | tee $(results.related_images_flag.path) exit 0 fi @@ -135,9 +136,12 @@ spec: RELATED_IMAGE_COUNT=$(yq -e '.spec.relatedImages | length' $CSVFILE) if [[ $RELATED_IMAGE_COUNT -ge $REFERENCE_COUNT ]]; then - echo "Related images section exists." + echo -n "Related images section exists." | tee $(results.related_images_message.path) echo -n "true" | tee $(results.related_images_flag.path) + elif [[ $RELATED_IMAGE_COUNT -lt $REFERENCE_COUNT && $RELATED_IMAGE_COUNT -gt 0 ]]; then + echo -n "The relatedImages section in your CSV covers only $RELATED_IMAGE_COUNT of the $REFERENCE_COUNT images detected in your CSV." | tee $(results.related_images_message.path) + echo -n "false" | tee $(results.related_images_flag.path) else - echo "The relatedImages section does not exist or is missing images." + echo -n "The relatedImages section is missing from the CSV" | tee $(results.related_images_message.path) echo -n "false" | tee $(results.related_images_flag.path) fi diff --git a/ansible/roles/operator-pipeline/templates/openshift/tasks/verify-pinned-digest.yml b/ansible/roles/operator-pipeline/templates/openshift/tasks/verify-pinned-digest.yml index c70ab708d..2e1680ad0 100644 --- a/ansible/roles/operator-pipeline/templates/openshift/tasks/verify-pinned-digest.yml +++ b/ansible/roles/operator-pipeline/templates/openshift/tasks/verify-pinned-digest.yml @@ -10,6 +10,7 @@ spec: default: "registry.access.redhat.com/ubi8-minimal@sha256:54ef2173bba7384dc7609e8affbae1c36f8a3ec137cacc0866116d65dd4b9afe" - name: dirty_flag - name: related_images_flag + - name: related_images_message steps: - name: check-dirty-flag image: "$(params.ubi8_minimal_image)" @@ -32,6 +33,6 @@ spec: RELATED_IMAGES_FLAG="$(params.related_images_flag)" echo $RELATED_IMAGES_FLAG if [ $RELATED_IMAGES_FLAG == "false" ]; then - echo "The relatedImages section is missing from the CSV" + echo "$(params.related_images_message)" exit 1 fi