Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: expose image manifest digest of all copied artifacts #1086

Merged
merged 2 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions task/oci-copy/0.1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ It is not to be considered safe for general use as it cannot provide a high degr
|---|---|
|IMAGE_DIGEST|Digest of the image just built|
|IMAGE_URL|Image repository where the built image was pushed|
|IMAGES|A comma separate list of all the individual image manifests produced|

## Workspaces
|name|description|optional|
Expand Down
25 changes: 21 additions & 4 deletions task/oci-copy/0.1/oci-copy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ spec:
name: IMAGE_DIGEST
- description: Repository where the artifact was pushed
name: IMAGE_URL
- description: URIs for all image manifests published, for signing
name: IMAGES
stepTemplate:
env:
- name: OCI_COPY_FILE
Expand Down Expand Up @@ -100,14 +102,29 @@ spec:
--all \
$IMAGE

cat "$(workspaces.source.path)"/image-digest | tee $(results.IMAGE_DIGEST.path)
echo -n "$IMAGE" | tee $(results.IMAGE_URL.path)
IMAGE_INDEX_DIGEST=$(cat "$(workspaces.source.path)"/image-digest)
echo -n "$IMAGE_INDEX_DIGEST" | tee "$(results.IMAGE_DIGEST.path)"
echo -n "$IMAGE" | tee "$(results.IMAGE_URL.path)"
buildah manifest inspect $IMAGE@$IMAGE_INDEX_DIGEST | tee "$(workspaces.source.path)"/image-manifests
volumeMounts:
- mountPath: /var/lib/containers
name: varlibcontainers
workingDir: $(workspaces.source.path)
- image: quay.io/konflux-ci/yq:latest@sha256:974dea6375ee9df561ffd3baf994db2b61777a71f3bcf0050c5dca91ac9b3430
name: sbom-generate

- name: artifact-manifest-generate
image: quay.io/konflux-ci/yq:latest@sha256:974dea6375ee9df561ffd3baf994db2b61777a71f3bcf0050c5dca91ac9b3430
script: |
MANIFEST_DIGESTS=$(cat "$(workspaces.source.path)"/image-manifests | yq -r '.manifests[].digest')
for MANIFEST_DIGEST in $MANIFEST_DIGESTS; do
reference="$IMAGE@$MANIFEST_DIGEST, "
echo "Writing ${reference} to $(results.IMAGES.path)"
echo -n "${reference}" >> $(results.IMAGES.path)
done
echo -n "$IMAGE@$(cat $(results.IMAGE_DIGEST.path))" >> $(results.IMAGES.path)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This imposes a pretty nasty limit on the number of images that this task can copy (before the result breaks the 4kb size limit). If the general expectation is that this task will be used for copying, say, 10 artifacts, we should be good. But maybe EC could (should it?) support signed index images referencing unsigned manifests?

workingDir: $(workspaces.source.path)

- name: sbom-generate
image: quay.io/konflux-ci/yq:latest@sha256:974dea6375ee9df561ffd3baf994db2b61777a71f3bcf0050c5dca91ac9b3430
script: |
cat >sbom-cyclonedx.json <<EOL
{
Expand Down