Skip to content

Commit

Permalink
feat(ISV-5447): add multi-arch and sha info to release note images
Browse files Browse the repository at this point in the history
Signed-off-by: Wai Cheang <wcheang@redhat.com>
  • Loading branch information
wcheang committed Dec 4, 2024
1 parent 070946e commit 0169878
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 deletions.
3 changes: 3 additions & 0 deletions tasks/populate-release-notes-images/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ in place so that downstream tasks relying on the releaseNotes data can use it.
| dataPath | Path to the JSON string of the merged data to update | No | - |
| snapshotPath | Path to the JSON string of the mapped Snapshot in the data workspace | No | - |

## Changes in 2.2.4
* Add `multiarch` and `imageSha` fields to release notes images

## Changes in 2.2.3
* Rename `components` in the CVE struct to `packages`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ kind: Task
metadata:
name: populate-release-notes-images
labels:
app.kubernetes.io/version: "2.2.3"
app.kubernetes.io/version: "2.2.4"
annotations:
tekton.dev/pipelines.minVersion: "0.12.1"
tekton.dev/tags: release
Expand Down Expand Up @@ -75,6 +75,7 @@ spec:
do
arch=$(jq -r .platform.architecture <<< "${arch_json}")
digest=$(jq -r .digest <<< "${arch_json}")
multiarch=$(jq -r .multiarch <<< "${arch_json}")
containerImage="${deliveryRepo}@${digest}"
# purl should be pkg:oci/bar@sha256%3Aabcde?arch=amd64&repository_url=registry.redhat.io/foo
purl="pkg:oci/${deliveryRepo##*/}@${digest/:/%3A}?arch=${arch}&repository_url=${deliveryRepo%/*}"
Expand All @@ -97,13 +98,15 @@ spec:
jsonString=$(jq -cn \
--arg component "$name" \
--arg arch "$arch" \
--arg multiarch "$multiarch" \
--arg sha "$sha" \
--arg containerImage "$containerImage" \
--arg purl "$purl" \
--arg repository "$deliveryRepo" \
--argjson tags "$tags" \
'{"architecture": $arch, "containerImage":$containerImage,
"purl": $purl, "repository": $repository, "tags": $tags,
"component": $component}')
'{"architecture": $arch, "multiarch": $multiarch, "imageSha": $sha,
"containerImage": $containerImage, "purl": $purl, "repository": $repository,
"tags": $tags, "component": $component}')
if [ $(jq '.cves.fixed | length' <<< $CVEsJson) -gt 0 ]; then
jsonString=$(jq --argjson cves "$CVEsJson" '. += $cves' <<< $jsonString)
fi
Expand Down
4 changes: 2 additions & 2 deletions tasks/populate-release-notes-images/tests/mocks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ set -eux
# mocks to be injected into task step scripts

function get-image-architectures() {
echo '{"platform":{"architecture": "amd64", "os": "linux"}, "digest": "sha256:abcdefg"}'
echo '{"platform":{"architecture": "s390x", "os": "linux"}, "digest": "sha256:deadbeef"}'
echo '{"platform":{"architecture": "amd64", "os": "linux"}, "digest": "sha256:abcdefg", "multiarch": true}'
echo '{"platform":{"architecture": "s390x", "os": "linux"}, "digest": "sha256:deadbeef" "multiarch": false}'
}
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ spec:
"pkg:oci/repo@sha256%3Aabcdefg?arch=amd64&repository_url=registry.redhat.io/product&tag=9.4.0-1723436855"
test $(jq -r '.repository' <<< $image1arch1) == "registry.redhat.io/product/repo"
test "$(jq -rc '.tags' <<< "$image1arch1")" == '["9.4-1723436855","9.4.0-1723436855","foo","bar"]'
test "$(jq -rc '.multiarch' <<< "$image1arch1")" == "true"
test "$(jq -rc '.imageSha' <<< "$image1arch1")" == "123456"
echo Checking image1arch2...
image1arch2=$(jq '.releaseNotes.content.images[1]' "$(workspaces.data.path)/data.json")
Expand All @@ -128,6 +130,8 @@ spec:
"pkg:oci/repo@sha256%3Adeadbeef?arch=s390x&repository_url=registry.redhat.io/product&tag=9.4.0-1723436855"
test $(jq -r '.repository' <<< $image1arch2) == "registry.redhat.io/product/repo"
test "$(jq -rc '.tags' <<< "$image1arch2")" == '["9.4-1723436855","9.4.0-1723436855","foo","bar"]'
test "$(jq -rc '.multiarch' <<< "$image1arch2")" == "false"
test "$(jq -rc '.imageSha' <<< "$image1arch2")" == "123456"
echo Checking image2arch1...
image2arch1=$(jq '.releaseNotes.content.images[2]' "$(workspaces.data.path)/data.json")
Expand All @@ -138,6 +142,8 @@ spec:
"pkg:oci/repo2@sha256%3Aabcdefg?arch=amd64&repository_url=registry.stage.redhat.io/product2"
test $(jq -r '.repository' <<< $image2arch1) == "registry.stage.redhat.io/product2/repo2"
test $(jq -rc '.tags' <<< $image2arch1) == '["foo","bar"]'
test "$(jq -rc '.multiarch' <<< "$image2arch1")" == "true"
test "$(jq -rc '.imageSha' <<< "$image2arch1")" == "abcde"
echo Checking image2arch2...
image2arch2=$(jq '.releaseNotes.content.images[3]' "$(workspaces.data.path)/data.json")
Expand All @@ -148,5 +154,7 @@ spec:
"pkg:oci/repo2@sha256%3Adeadbeef?arch=s390x&repository_url=registry.stage.redhat.io/product2"
test $(jq -r '.repository' <<< $image2arch2) == "registry.stage.redhat.io/product2/repo2"
test $(jq -rc '.tags' <<< $image2arch2) == '["foo","bar"]'
test "$(jq -rc '.multiarch' <<< "$image2arch2")" == "false"
test "$(jq -rc '.imageSha' <<< "$image2arch2")" == "abcde"
runAfter:
- run-task
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ spec:
test $(jq -r '.repository' <<< $imagearch1) == "registry.redhat.io/product/repo"
test $(jq -rc '.tags' <<< $imagearch1) == '["foo","bar"]'
test "$(jq -rc '.component' <<< "$imagearch1")" == "comp"
test "$(jq -rc '.multiarch' <<< "$imagearch1")" == "true"
test "$(jq -rc '.imageSha' <<< "$imagearch1")" == "123456"
imagearch2=$(jq '.releaseNotes.content.images[1]' "$(workspaces.data.path)/data.json")
test $(jq -r '.architecture' <<< $imagearch2) == "s390x"
Expand All @@ -116,5 +118,7 @@ spec:
test $(jq -r '.repository' <<< $imagearch2) == "registry.redhat.io/product/repo"
test $(jq -rc '.tags' <<< $imagearch2) == '["foo","bar"]'
test "$(jq -rc '.component' <<< "$imagearch2")" == "comp"
test "$(jq -rc '.multiarch' <<< "$imagearch2")" == "false"
test "$(jq -rc '.imageSha' <<< "$imagearch2")" == "123456"
runAfter:
- run-task

0 comments on commit 0169878

Please sign in to comment.