Skip to content

Commit 1da115f

Browse files
committed
fix: user index_image_resolved as source
Signed-off-by: Leandro Mendes <lmendes@redhat.com>
1 parent bf52d36 commit 1da115f

2 files changed

Lines changed: 45 additions & 57 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: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ spec:
152152
153153
sourceIndex="$(jq -r --argjson i "$i" \
154154
'.components[$i].index_image' "$(params.dataDir)/$(params.internalRequestResultsFile)")"
155-
sourceResolvedIndex="$(jq -r --argjson i "$i" \
155+
sourceIndexResolved="$(jq -r --argjson i "$i" \
156156
'.components[$i].index_image_resolved' "$(params.dataDir)/$(params.internalRequestResultsFile)")"
157157
158158
targetOcpVersion=$(jq -r --argjson i "$i" \
@@ -175,14 +175,10 @@ spec:
175175
for((x=0; x<${#publishingImages[@]}; x++ )); do
176176
echo "=== Creating internal request to publish image:"
177177
echo ""
178-
179-
# if we are pushing the timestamped index (always the index #1), we should
180-
# use index_image_resolved instead, because the target_index sha can poten_
181-
# tially be changed by a concurrent fbc process.
182178
if [ "$x" -eq 1 ]; then
183-
sourceIndex="$sourceResolvedIndex"
179+
sourceIndex="$sourceIndexResolved"
184180
fi
185-
echo "- from: ${sourceIndex}"
181+
echo "- from: ${sourceIndexResolved}"
186182
echo "- to: ${publishingImages[$x]}"
187183
188184
internal-request --pipeline "${request}" \

0 commit comments

Comments
 (0)