From 7e809ce98431110a678f8cc2ad777a5d28bcad8b Mon Sep 17 00:00:00 2001 From: Johnny Bieren Date: Thu, 25 Jun 2026 13:28:53 -0400 Subject: [PATCH] refactor(RELEASE-2479): convert collect-index-images to python This commit replaces the inline task script for collect-index-images with a standalone python script contained in the utils image. The tekton unit tests are updated accordingly. We only keep one happy path test as the other scenarios are covered by pytest in the utils repo. Signed-off-by: Johnny Bieren --- .../collect-index-images.yaml | 77 +++---------------- .../test-collect-index-images-hotfix.yaml | 4 +- ...ollect-index-images-multiple-versions.yaml | 4 +- ...t-collect-index-images-single-version.yaml | 4 +- 4 files changed, 17 insertions(+), 72 deletions(-) diff --git a/tasks/managed/collect-index-images/collect-index-images.yaml b/tasks/managed/collect-index-images/collect-index-images.yaml index 5930bfee7b..e709ce3b96 100644 --- a/tasks/managed/collect-index-images/collect-index-images.yaml +++ b/tasks/managed/collect-index-images/collect-index-images.yaml @@ -111,78 +111,23 @@ spec: - name: sourceDataArtifact value: $(params.sourceDataArtifact) - name: collect-index-images - image: - quay.io/konflux-ci/release-service-utils@sha256:5546fa78d3c88d7b6a2e8cff8902f7757f00541d0bbaf113b9f293133894afa3 + image: quay.io/jbieren/release-service-utils:collectindex_2 computeResources: limits: memory: 128Mi requests: memory: 128Mi cpu: 50m - script: | - #!/usr/bin/env bash - set -eux - - RESULTS_FILE=$(params.dataDir)/$(params.internalRequestResultsFile) - SNAPSHOT_FILE=$(params.dataDir)/index_image_snapshot.json - jq -n '{"components": []}' | tee "$SNAPSHOT_FILE" - - LENGTH="$(jq -r '.components | length' "$RESULTS_FILE")" - for((i=0; i" or "v4.13-product-1.0-"), so appending - # a second timestamp would create a redundant tag. - if [[ "${TAG}" =~ ^v[0-9]+\.[0-9]+$ ]]; then - TAGS+=("${TAG}-$(params.buildTimestamp)") - fi - JSON_TAGS=$(jq -n -c '$ARGS.positional' --args -- "${TAGS[@]}") - - # Translate target_index to get rh-registry-repo and registry-access-repo - TRANSLATED=$(translate-delivery-repo "$TARGETINDEX") - RH_REGISTRY_REPO=$(jq -r '.[] | select(.repo=="redhat.io") | .url' <<< "$TRANSLATED" \ - | cut -d':' -f1) - REGISTRY_ACCESS_REPO=$(jq -r '.[] | select(.repo=="access.redhat.com") | .url' \ - <<< "$TRANSLATED" | cut -d':' -f1) - - # Build repository object with translated fields - REPO_OBJECT=$(jq -n \ - --arg url "${REPOSITORY}" \ - --argjson tags "${JSON_TAGS}" \ - --arg rh_registry_repo "${RH_REGISTRY_REPO}" \ - --arg registry_access_repo "${REGISTRY_ACCESS_REPO}" \ - '{ - "url": $url, - "tags": $tags - } + (if $rh_registry_repo != "" then {"rh-registry-repo": $rh_registry_repo} else {} end) - + (if $registry_access_repo != "" then {"registry-access-repo": $registry_access_repo} else {} end)' - ) - - COMPONENT=$(jq -n \ - --arg image "${SOURCEINDEX}" \ - --arg repository "${REPOSITORY}" \ - --argjson tags "${JSON_TAGS}" \ - --argjson image_digests "${IMAGE_DIGESTS}" \ - --argjson repo_object "${REPO_OBJECT}" \ - '{ - "containerImage": $image, - "repository": $repository, - "repositories": [$repo_object], - "tags": $tags, - "imageDigests": $image_digests - }' - ) - export COMPONENT - yq -i '.components += env(COMPONENT) ' "$SNAPSHOT_FILE" - done - echo -n "index_image_snapshot.json" > "$(results.indexImageSnapshot.path)" + env: + - name: PARAM_DATA_DIR + value: $(params.dataDir) + - name: PARAM_INTERNAL_REQUEST_RESULTS_FILE + value: $(params.internalRequestResultsFile) + - name: PARAM_BUILD_TIMESTAMP + value: $(params.buildTimestamp) + - name: RESULT_INDEX_IMAGE_SNAPSHOT_PATH + value: $(results.indexImageSnapshot.path) + command: ["/home/scripts/python/tasks/managed/collect_index_images.py"] - name: create-trusted-artifact computeResources: limits: diff --git a/tasks/managed/collect-index-images/tests/test-collect-index-images-hotfix.yaml b/tasks/managed/collect-index-images/tests/test-collect-index-images-hotfix.yaml index 3439e7df7b..e6e001e0f7 100644 --- a/tasks/managed/collect-index-images/tests/test-collect-index-images-hotfix.yaml +++ b/tasks/managed/collect-index-images/tests/test-collect-index-images-hotfix.yaml @@ -49,7 +49,7 @@ spec: value: "$(params.trustedArtifactsDebug)" steps: - name: setup-values - image: quay.io/konflux-ci/release-service-utils@sha256:5546fa78d3c88d7b6a2e8cff8902f7757f00541d0bbaf113b9f293133894afa3 + image: quay.io/jbieren/release-service-utils:collectindex_2 script: | #!/usr/bin/env sh set -eux @@ -139,7 +139,7 @@ spec: - name: sourceDataArtifact value: $(params.sourceDataArtifact) - name: check-result - image: quay.io/konflux-ci/release-service-utils@sha256:5546fa78d3c88d7b6a2e8cff8902f7757f00541d0bbaf113b9f293133894afa3 + image: quay.io/jbieren/release-service-utils:collectindex_2 script: | #!/usr/bin/env bash set -eux diff --git a/tasks/managed/collect-index-images/tests/test-collect-index-images-multiple-versions.yaml b/tasks/managed/collect-index-images/tests/test-collect-index-images-multiple-versions.yaml index d350a2544d..57ab5b3731 100644 --- a/tasks/managed/collect-index-images/tests/test-collect-index-images-multiple-versions.yaml +++ b/tasks/managed/collect-index-images/tests/test-collect-index-images-multiple-versions.yaml @@ -48,7 +48,7 @@ spec: value: "$(params.trustedArtifactsDebug)" steps: - name: setup-values - image: quay.io/konflux-ci/release-service-utils@sha256:5546fa78d3c88d7b6a2e8cff8902f7757f00541d0bbaf113b9f293133894afa3 + image: quay.io/jbieren/release-service-utils:collectindex_2 script: | #!/usr/bin/env sh set -eux @@ -138,7 +138,7 @@ spec: - name: sourceDataArtifact value: $(params.sourceDataArtifact) - name: check-result - image: quay.io/konflux-ci/release-service-utils@sha256:5546fa78d3c88d7b6a2e8cff8902f7757f00541d0bbaf113b9f293133894afa3 + image: quay.io/jbieren/release-service-utils:collectindex_2 script: | #!/usr/bin/env bash set -eux diff --git a/tasks/managed/collect-index-images/tests/test-collect-index-images-single-version.yaml b/tasks/managed/collect-index-images/tests/test-collect-index-images-single-version.yaml index 01d02ee446..591292ccae 100644 --- a/tasks/managed/collect-index-images/tests/test-collect-index-images-single-version.yaml +++ b/tasks/managed/collect-index-images/tests/test-collect-index-images-single-version.yaml @@ -48,7 +48,7 @@ spec: value: "$(params.trustedArtifactsDebug)" steps: - name: setup-values - image: quay.io/konflux-ci/release-service-utils@sha256:5546fa78d3c88d7b6a2e8cff8902f7757f00541d0bbaf113b9f293133894afa3 + image: quay.io/jbieren/release-service-utils:collectindex_2 script: | #!/usr/bin/env sh set -eux @@ -134,7 +134,7 @@ spec: - name: sourceDataArtifact value: $(params.sourceDataArtifact) - name: check-result - image: quay.io/konflux-ci/release-service-utils@sha256:5546fa78d3c88d7b6a2e8cff8902f7757f00541d0bbaf113b9f293133894afa3 + image: quay.io/jbieren/release-service-utils:collectindex_2 script: | #!/usr/bin/env bash set -eux