Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 11 additions & 66 deletions tasks/managed/collect-index-images/collect-index-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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<LENGTH; i++)); do
TARGETINDEX=$(jq -r --argjson i "$i" '.components[$i].target_index' "$RESULTS_FILE")
SOURCEINDEX=$(jq -r --argjson i "$i" '.components[$i].index_image_resolved' "$RESULTS_FILE")
IMAGE_DIGESTS=$(jq -c --argjson i "$i" '.components[$i].image_digests // []' "$RESULTS_FILE")
REPOSITORY=${TARGETINDEX%:*}

TAG=${TARGETINDEX#*:}
TAGS=("${TAG}")
# Only add a buildTimestamp tag for bare OCP version tags (e.g., "v4.13").
# Hotfix and pre-GA tags already have unique suffixes from prepare-fbc-snapshot
# (e.g., "v4.13-RELEASE-1234-<ts>" or "v4.13-product-1.0-<ts>"), 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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading