From 7f9f26db681c8b2a23e963338bf78ab9f421dcf5 Mon Sep 17 00:00:00 2001 From: Johnny Bieren Date: Mon, 16 Dec 2024 07:37:44 -0500 Subject: [PATCH] fix(RELEASE-1071): linting issues in extract-index-image (#740) Signed-off-by: Johnny Bieren --- tasks/extract-index-image/README.md | 3 +++ .../extract-index-image.yaml | 16 ++++++++-------- ...ract-index-image-fail-no-inputdatafile.yaml | 2 +- .../tests/test-extract-index-image.yaml | 18 +++++++++--------- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/tasks/extract-index-image/README.md b/tasks/extract-index-image/README.md index 1997a9bc7..ccacce4d9 100644 --- a/tasks/extract-index-image/README.md +++ b/tasks/extract-index-image/README.md @@ -12,6 +12,9 @@ the workspace name for this task *must* be input. | inputDataFile | File to read json data from | No | - | | resultsDirPath | Path to results directory in the data workspace | No | - | +## Changes in 1.1.1 +* Fix shellcheck/checkton linting issues in the task and tests + ## Changes in 1.1.0 * Updated the base image used in this task diff --git a/tasks/extract-index-image/extract-index-image.yaml b/tasks/extract-index-image/extract-index-image.yaml index 6b5001468..e20485dea 100644 --- a/tasks/extract-index-image/extract-index-image.yaml +++ b/tasks/extract-index-image/extract-index-image.yaml @@ -4,7 +4,7 @@ kind: Task metadata: name: extract-index-image labels: - app.kubernetes.io/version: "1.1.0" + app.kubernetes.io/version: "1.1.1" annotations: tekton.dev/pipelines.minVersion: "0.12.1" tekton.dev/tags: release @@ -30,18 +30,18 @@ spec: image: >- quay.io/konflux-ci/release-service-utils:e633d51cd41d73e4b3310face21bb980af7a662f script: | - #!/usr/bin/env sh + #!/usr/bin/env bash set -ex RESULTS_FILE="$(workspaces.data.path)/$(params.resultsDirPath)/extract-index-image-results.json" - jsonBuildInfo=`jq -cr .jsonBuildInfo $(params.inputDataFile)` + jsonBuildInfo=$(jq -cr .jsonBuildInfo "$(params.inputDataFile)") - indexImage=`echo $jsonBuildInfo | jq -cr .index_image` - echo -n $indexImage > $(results.indexImage.path) + indexImage=$(echo "$jsonBuildInfo" | jq -cr .index_image) + echo -n "$indexImage" > "$(results.indexImage.path)" - indexImageResolved=`echo $jsonBuildInfo | jq -cr .index_image_resolved` - echo -n $indexImageResolved > $(results.indexImageResolved.path) + indexImageResolved=$(echo "$jsonBuildInfo" | jq -cr .index_image_resolved) + echo -n "$indexImageResolved" > "$(results.indexImageResolved.path)" jq -n --arg image "$indexImage" --arg resolved "$indexImageResolved" \ - '{"index_image": {"index_image": $image, "index_image_resolved": $resolved}}' | tee $RESULTS_FILE + '{"index_image": {"index_image": $image, "index_image_resolved": $resolved}}' | tee "$RESULTS_FILE" diff --git a/tasks/extract-index-image/tests/test-extract-index-image-fail-no-inputdatafile.yaml b/tasks/extract-index-image/tests/test-extract-index-image-fail-no-inputdatafile.yaml index b11029b04..8f69ffcfb 100644 --- a/tasks/extract-index-image/tests/test-extract-index-image-fail-no-inputdatafile.yaml +++ b/tasks/extract-index-image/tests/test-extract-index-image-fail-no-inputdatafile.yaml @@ -26,7 +26,7 @@ spec: #!/usr/bin/env sh set -eux - mkdir $(workspaces.data.path)/results + mkdir "$(workspaces.data.path)/results" - name: run-task taskRef: name: extract-index-image diff --git a/tasks/extract-index-image/tests/test-extract-index-image.yaml b/tasks/extract-index-image/tests/test-extract-index-image.yaml index b051e8122..061a82f47 100644 --- a/tasks/extract-index-image/tests/test-extract-index-image.yaml +++ b/tasks/extract-index-image/tests/test-extract-index-image.yaml @@ -24,8 +24,8 @@ spec: #!/usr/bin/env sh set -eux - mkdir $(workspaces.data.path)/results - cat > $(workspaces.data.path)/file.json << EOF + mkdir "$(workspaces.data.path)/results" + cat > "$(workspaces.data.path)/file.json" << EOF { "jsonBuildInfo": { "arches": [ @@ -93,21 +93,21 @@ spec: - name: check-result image: quay.io/konflux-ci/release-service-utils:e633d51cd41d73e4b3310face21bb980af7a662f script: | - #!/usr/bin/env sh + #!/usr/bin/env bash set -eux echo Test the indexImage result was properly set - test $(echo $(params.indexImage)) == "redhat.com/rh-stage/iib:01" + test "$(params.indexImage)" == "redhat.com/rh-stage/iib:01" echo Test the indexImageResolved result was properly set - test $(echo $(params.indexImageResolved)) == "redhat.com/rh-stage/iib@sha256:abcdefghijk" + test "$(params.indexImageResolved)" == "redhat.com/rh-stage/iib@sha256:abcdefghijk" echo Check the results file - test $(jq -r '.index_image.index_image' \ - $(workspaces.data.path)/results/extract-index-image-results.json) == \ + test "$(jq -r '.index_image.index_image' \ + "$(workspaces.data.path)/results/extract-index-image-results.json")" == \ "redhat.com/rh-stage/iib:01" - test $(jq -r '.index_image.index_image_resolved' \ - $(workspaces.data.path)/results/extract-index-image-results.json) == \ + test "$(jq -r '.index_image.index_image_resolved' \ + "$(workspaces.data.path)/results/extract-index-image-results.json")" == \ "redhat.com/rh-stage/iib@sha256:abcdefghijk" runAfter: - run-task