From 34d2300f0f9c5f13aaa272869ea53f3274c2c7bd Mon Sep 17 00:00:00 2001 From: Johnny Bieren Date: Tue, 17 Dec 2024 17:14:58 -0500 Subject: [PATCH] fix(RELEASE-1090): linting issues in sign-index-image (#747) Signed-off-by: Johnny Bieren --- ...ign-index-image-with-pullspec-rewrite.yaml | 21 +++++++++--------- .../tests/test-sign-index-image.yaml | 22 +++++++++---------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/tasks/sign-index-image/tests/test-sign-index-image-with-pullspec-rewrite.yaml b/tasks/sign-index-image/tests/test-sign-index-image-with-pullspec-rewrite.yaml index b2b78ef70..4d6e7926e 100644 --- a/tasks/sign-index-image/tests/test-sign-index-image-with-pullspec-rewrite.yaml +++ b/tasks/sign-index-image/tests/test-sign-index-image-with-pullspec-rewrite.yaml @@ -19,10 +19,10 @@ spec: - name: setup-values image: quay.io/konflux-ci/release-service-utils:e633d51cd41d73e4b3310face21bb980af7a662f script: | - #!/usr/bin/env sh + #!/usr/bin/env bash set -eux - cat > $(workspaces.data.path)/data.json << EOF + cat > "$(workspaces.data.path)/data.json" << EOF { "sign": { "configMapName": "signing-config-map" @@ -92,32 +92,33 @@ spec: #!/usr/bin/env bash set -eux - internalRequest="$(kubectl get internalrequest --sort-by=.metadata.creationTimestamp --no-headers)" - params=$(kubectl get internalrequest ${internalRequest} -o jsonpath="{.spec.params}") + internalRequest="$(kubectl get internalrequest --sort-by=.metadata.creationTimestamp --no-headers \ + -o custom-columns=":metadata.name")" + params=$(kubectl get internalrequest "${internalRequest}" -o jsonpath="{.spec.params}") - if [ $(jq -r '.reference' <<< "${params}") != "registry.redhat.io/redhat/testimage:tag" ]; then + if [ "$(jq -r '.reference' <<< "${params}")" != "registry.redhat.io/redhat/testimage:tag" ]; then echo "reference image does not match" exit 1 fi - if [ $(jq -r '.manifest_digest' <<< "${params}") != "sha256:6f9a420f660e73b" ]; then + if [ "$(jq -r '.manifest_digest' <<< "${params}")" != "sha256:6f9a420f660e73b" ]; then echo "manifest_digest does not match" exit 1 fi - if [ $(jq -r '.config_map_name' <<< "${params}") != "signing-config-map" ] + if [ "$(jq -r '.config_map_name' <<< "${params}")" != "signing-config-map" ] then echo "config_map_name does not match" exit 1 fi - if [ $(jq -r '.requester' <<< "${params}") != "testuser" ] + if [ "$(jq -r '.requester' <<< "${params}")" != "testuser" ] then echo "requester does not match" exit 1 fi - if [ $(jq -r '.pipeline_image' <<< "${params}") != \ + if [ "$(jq -r '.pipeline_image' <<< "${params}")" != \ "quay.io/redhat-isv/operator-pipelines-images:released" ] then echo "pipeline_image does not match" @@ -132,7 +133,7 @@ spec: - name: delete-crs image: quay.io/konflux-ci/release-service-utils:e633d51cd41d73e4b3310face21bb980af7a662f script: | - #!/usr/bin/env sh + #!/usr/bin/env bash set -eux kubectl delete internalrequests --all diff --git a/tasks/sign-index-image/tests/test-sign-index-image.yaml b/tasks/sign-index-image/tests/test-sign-index-image.yaml index 3eee493d9..a559cf863 100644 --- a/tasks/sign-index-image/tests/test-sign-index-image.yaml +++ b/tasks/sign-index-image/tests/test-sign-index-image.yaml @@ -19,10 +19,10 @@ spec: - name: setup-values image: quay.io/konflux-ci/release-service-utils:e633d51cd41d73e4b3310face21bb980af7a662f script: | - #!/usr/bin/env sh + #!/usr/bin/env bash set -eux - cat > $(workspaces.data.path)/data.json << EOF + cat > "$(workspaces.data.path)/data.json" << EOF { "sign": { "configMapName": "signing-config-map" @@ -96,40 +96,40 @@ spec: testValues=('sha256:6f9a420f660e73a' \ 'sha256:6f9a420f660e73b') internalRequests="$(kubectl get internalrequest --sort-by=.metadata.creationTimestamp --no-headers)" - internalRequestsCount=$(echo $internalRequests | wc -w) + internalRequestsCount=$(echo "$internalRequests" | wc -w) - if [ $internalRequestsCount != "2" ] ; then + if [ "$internalRequestsCount" != "2" ] ; then echo "incorrect number of internalRequests created. Expected 2" exit 1 fi for internalRequest in ${internalRequests}; do - params=$(kubectl get internalrequest ${internalRequest} -o jsonpath="{.spec.params}") + params=$(kubectl get internalrequest "${internalRequest}" -o jsonpath="{.spec.params}") - if [ $(jq -r '.reference' <<< "${params}") != "quay.io/testrepo/testimage:tag" ]; then + if [ "$(jq -r '.reference' <<< "${params}")" != "quay.io/testrepo/testimage:tag" ]; then echo "reference image does not match" exit 1 fi - if [ $(jq -r '.manifest_digest' <<< "${params}") != "${testValues[$counter]}" ]; then + if [ "$(jq -r '.manifest_digest' <<< "${params}")" != "${testValues[$counter]}" ]; then echo "manifest_digest does not match" exit 1 fi - if [ $(jq -r '.config_map_name' <<< "${params}") != "signing-config-map" ] + if [ "$(jq -r '.config_map_name' <<< "${params}")" != "signing-config-map" ] then echo "config_map_name does not match" exit 1 fi - if [ $(jq -r '.requester' <<< "${params}") != "testuser" ] + if [ "$(jq -r '.requester' <<< "${params}")" != "testuser" ] then echo "requester does not match" exit 1 fi - if [ $(jq -r '.pipeline_image' <<< "${params}") != \ + if [ "$(jq -r '.pipeline_image' <<< "${params}")" != \ "quay.io/redhat-isv/operator-pipelines-images:released" ] then echo "pipeline_image does not match" @@ -147,7 +147,7 @@ spec: - name: delete-crs image: quay.io/konflux-ci/release-service-utils:e633d51cd41d73e4b3310face21bb980af7a662f script: | - #!/usr/bin/env sh + #!/usr/bin/env bash set -eux kubectl delete internalrequests --all