Skip to content

Commit 47d33a3

Browse files
committed
fix
1 parent 2d638d5 commit 47d33a3

2 files changed

Lines changed: 48 additions & 51 deletions

File tree

tasks/managed/collect-index-images/collect-index-images.yaml

Lines changed: 42 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -130,61 +130,53 @@ spec:
130130
TARGETINDEX_TS=$(jq -r --argjson i "$i" '.components[$i].target_index_with_timestamp' "$RESULTS_FILE")
131131
SOURCEINDEX=$(jq -r --argjson i "$i" '.components[$i].index_image_resolved' "$RESULTS_FILE")
132132
IMAGE_DIGESTS=$(jq -c --argjson i "$i" '.components[$i].image_digests // []' "$RESULTS_FILE")
133-
COMPLETION_TIME=$(jq -r --argjson i "$i" '.components[$i].completion_time // empty' "$RESULTS_FILE")
134133
135-
# Validate completion_time is present
136-
if [[ -z "${COMPLETION_TIME}" || "${COMPLETION_TIME}" == "null" ]]; then
137-
echo "ERROR: Component $i missing completion_time in results file"
138-
exit 1
139-
fi
134+
# create pyxis entry for the component for tags in separated
135+
for TARGET in $TARGETINDEX $TARGETINDEX_TS; do
136+
REPOSITORY=${TARGET%:*}
140137
141-
REPOSITORY=${TARGETINDEX%:*}
138+
TAG=${TARGET#*:}
139+
TAGS=("${TAG}")
140+
JSON_TAGS=$(jq -n -c '$ARGS.positional' --args -- "${TAGS[@]}")
142141
143-
TAG=${TARGETINDEX#*:}
144-
TAGS=("${TAG}")
145-
if [[ "${TARGETINDEX}" != "${TARGETINDEX_TS}" ]]; then
146-
TAG=${TARGETINDEX_TS#*:}
147-
TAGS+=("${TAG}")
148-
fi
149-
JSON_TAGS=$(jq -n -c '$ARGS.positional' --args -- "${TAGS[@]}")
142+
# Translate target_index to get rh-registry-repo and registry-access-repo
143+
TRANSLATED=$(translate-delivery-repo "$TARGETINDEX")
144+
RH_REGISTRY_REPO=$(jq -r '.[] | select(.repo=="redhat.io") | .url' <<< "$TRANSLATED" \
145+
| cut -d':' -f1)
146+
REGISTRY_ACCESS_REPO=$(jq -r '.[] | select(.repo=="access.redhat.com") | .url' \
147+
<<< "$TRANSLATED" | cut -d':' -f1)
150148
151-
# Translate target_index to get rh-registry-repo and registry-access-repo
152-
TRANSLATED=$(translate-delivery-repo "$TARGETINDEX")
153-
RH_REGISTRY_REPO=$(jq -r '.[] | select(.repo=="redhat.io") | .url' <<< "$TRANSLATED" \
154-
| cut -d':' -f1)
155-
REGISTRY_ACCESS_REPO=$(jq -r '.[] | select(.repo=="access.redhat.com") | .url' \
156-
<<< "$TRANSLATED" | cut -d':' -f1)
149+
# Build repository object with translated fields
150+
REPO_OBJECT=$(jq -n \
151+
--arg url "${REPOSITORY}" \
152+
--argjson tags "${JSON_TAGS}" \
153+
--arg rh_registry_repo "${RH_REGISTRY_REPO}" \
154+
--arg registry_access_repo "${REGISTRY_ACCESS_REPO}" \
155+
'{
156+
"url": $url,
157+
"tags": $tags
158+
} + (if $rh_registry_repo != "" then {"rh-registry-repo": $rh_registry_repo} else {} end)
159+
+ (if $registry_access_repo != "" then {"registry-access-repo": $registry_access_repo} else {} end)'
160+
)
157161
158-
# Build repository object with translated fields
159-
REPO_OBJECT=$(jq -n \
160-
--arg url "${REPOSITORY}" \
161-
--argjson tags "${JSON_TAGS}" \
162-
--arg rh_registry_repo "${RH_REGISTRY_REPO}" \
163-
--arg registry_access_repo "${REGISTRY_ACCESS_REPO}" \
164-
'{
165-
"url": $url,
166-
"tags": $tags
167-
} + (if $rh_registry_repo != "" then {"rh-registry-repo": $rh_registry_repo} else {} end)
168-
+ (if $registry_access_repo != "" then {"registry-access-repo": $registry_access_repo} else {} end)'
169-
)
170-
171-
COMPONENT=$(jq -n \
172-
--arg image "${SOURCEINDEX}" \
173-
--arg repository "${REPOSITORY}" \
174-
--argjson tags "${JSON_TAGS}" \
175-
--argjson image_digests "${IMAGE_DIGESTS}" \
176-
--argjson repo_object "${REPO_OBJECT}" \
177-
'{
178-
"containerImage": $image,
179-
"repository": $repository,
180-
"repositories": [$repo_object],
181-
"tags": $tags,
182-
"imageDigests": $image_digests
183-
}'
184-
)
185-
export COMPONENT
186-
yq -i '.components += env(COMPONENT) ' "$SNAPSHOT_FILE"
187-
done
162+
COMPONENT=$(jq -n \
163+
--arg image "${SOURCEINDEX}" \
164+
--arg repository "${REPOSITORY}" \
165+
--argjson tags "${JSON_TAGS}" \
166+
--argjson image_digests "${IMAGE_DIGESTS}" \
167+
--argjson repo_object "${REPO_OBJECT}" \
168+
'{
169+
"containerImage": $image,
170+
"repository": $repository,
171+
"repositories": [$repo_object],
172+
"tags": $tags,
173+
"imageDigests": $image_digests
174+
}'
175+
)
176+
export COMPONENT
177+
yq -i '.components += env(COMPONENT) ' "$SNAPSHOT_FILE"
178+
done # end taget index loop
179+
done # end components loop
188180
echo -n "index_image_snapshot.json" > "$(results.indexImageSnapshot.path)"
189181
- name: create-trusted-artifact
190182
computeResources:

tasks/managed/publish-index-image/publish-index-image.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ spec:
150150
targetIndexWithTimestamp=$(jq -r --argjson i "$i" \
151151
'.components[$i].target_index_with_timestamp' "$(params.dataDir)/$(params.internalRequestResultsFile)")
152152
153+
sourceIndex="$(jq -r --argjson i "$i" \
154+
'.components[$i].index_image' "$(params.dataDir)/$(params.internalRequestResultsFile)")"
153155
sourceIndexResolved="$(jq -r --argjson i "$i" \
154156
'.components[$i].index_image_resolved' "$(params.dataDir)/$(params.internalRequestResultsFile)")"
155157
@@ -173,11 +175,14 @@ spec:
173175
for((x=0; x<${#publishingImages[@]}; x++ )); do
174176
echo "=== Creating internal request to publish image:"
175177
echo ""
178+
if [ "$x" -eq 1 ]; then
179+
sourceIndex="$sourceIndexResolved"
180+
fi
176181
echo "- from: ${sourceIndexResolved}"
177182
echo "- to: ${publishingImages[$x]}"
178183
179184
internal-request --pipeline "${request}" \
180-
-p sourceIndex="${sourceIndexResolved}" \
185+
-p sourceIndex="${sourceIndex}" \
181186
-p targetIndex="${publishingImages[$x]}" \
182187
-p targetOcpVersion="${targetOcpVersion}" \
183188
-p publishingCredentials="${credentials}" \

0 commit comments

Comments
 (0)