Get image id.

This commit is contained in:
Tom Alexander
2026-09-07 18:15:43 -04:00
parent 64bee2bb1b
commit 9c6d3bc418

View File

@@ -98,7 +98,8 @@ spec:
additional_args+=(--ssh default=\$SSH_AUTH_SOCK) additional_args+=(--ssh default=\$SSH_AUTH_SOCK)
fi fi
exec buildah build "\${additional_args[@]}" "\${@}" buildah build "\${additional_args[@]}" "\${@}"
exec buildah push --storage-driver overlay $(params.OUTPUT)
EOF EOF
chmod +x /home/build/.config/containers/entrypoint.sh chmod +x /home/build/.config/containers/entrypoint.sh
@@ -162,20 +163,17 @@ spec:
- name: read-metadata - name: read-metadata
image: python:3.13-alpine3.20 image: python:3.13-alpine3.20
workingDir: "$(workspaces.source.path)" workingDir: "$(workspaces.source.path)"
# at this point /home/build/.metadata/image_id has contents like:
# sha256:7102ad507cf1b0c8adfa99a081ddfd0b5dc11e2d971162316753a58ce2b7f6ca
script: | script: |
#!/usr/bin/env bash
cat /home/build/.metadata/image_id
echo "---"
#!/usr/bin/env python #!/usr/bin/env python
import json import json
with open("/home/build/.metadata/build.json", "r") as f: with open("/home/build/.metadata/image_id", "r") as f:
meta_body = f.read() image_id = f.read()
print(meta_body)
meta = json.loads(meta_body)
with open("$(results.IMAGE_DIGEST.path)", "w") as f: with open("$(results.IMAGE_DIGEST.path)", "w") as f:
print(meta["containerimage.digest"], file=f, end="") print(json.dumps([image_id]), file=f, end="")
with open("$(results.IMAGE_URL.path)", "w") as f: with open("$(results.IMAGE_URL.path)", "w") as f:
print(json.dumps(meta["image.name"].split(",")), file=f, end="") print(json.dumps(["$(params.OUTPUT)"]), file=f, end="")
volumeMounts: volumeMounts:
- name: metadata-out - name: metadata-out
mountPath: /home/build/.metadata mountPath: /home/build/.metadata