Skip to content

Commit

Permalink
Report image manifest pullspec as result
Browse files Browse the repository at this point in the history
  • Loading branch information
ralphbean committed Jul 10, 2024
1 parent 090425c commit 222266a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions task/build-vm-image/0.1/build-vm-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ spec:
# this quoted heredoc prevents expansions and command substitutions. the env vars are evaluated on the remote vm
cat >>scripts/script-push.sh <<'REMOTESSHEOF'
dnf -y install buildah pigz jq
dnf -y install buildah skopeo pigz jq
# Build an image index of length 1 referring to an image manifest with the content
buildah --storage-driver=vfs manifest create "$OUTPUT_IMAGE"
Expand All @@ -240,15 +240,19 @@ spec:
# At this point, we have pushed an image index of length 1 to the registry.
# Next, extract a reference to the image manifest and expose that, throwing away the image index.
IMAGE_INDEX_DIGEST=$(cat image-digest)
MANIFEST_DIGEST=$(buildah manifest inspect --authfile /.docker/config.json $OUTPUT_IMAGE@$IMAGE_INDEX_DIGEST | jq '.manifests[0].digest')
REPO=${OUTPUT_IMAGE%:*}
MANIFEST_DIGEST=$(buildah manifest inspect --authfile /.docker/config.json $REPO@$IMAGE_INDEX_DIGEST | jq -r '.manifests[0].digest')
# Overwrite the image index pullspec tag with the image manifest one
skopeo copy --authfile /.docker/config.json docker://$REPO@$MANIFEST_DIGEST docker://$OUTPUT_IMAGE
# Finally, record all that in our results
echo -n "$OUTPUT_IMAGE" | tee /tekton-results/IMAGE_URL
echo $MANIFEST_DIGEST | tee /tekton-results/IMAGE_DIGEST
REMOTESSHEOF
# make scripts executable and sync them to the cloud VM.
chmod +x scripts/script-build.sh
chmod +x scripts/script-push.sh
rsync -ra scripts "$SSH_HOST:$BUILD_DIR"
Expand Down

0 comments on commit 222266a

Please sign in to comment.