From c703c791d4485b4accdc2f6c119a725919f331c3 Mon Sep 17 00:00:00 2001 From: Laurent Goderre Date: Fri, 13 Sep 2024 14:54:23 -0400 Subject: [PATCH] Modify index munge for verification Preserves the image.ref.name annotatoon and set it to the first arch tag --- .test/meta-commands/out.sh | 12 +++++++++--- meta.jq | 12 +++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/.test/meta-commands/out.sh b/.test/meta-commands/out.sh index 340cffa..c3623e2 100644 --- a/.test/meta-commands/out.sh +++ b/.test/meta-commands/out.sh @@ -45,11 +45,17 @@ tar -xvf temp.tar -C temp rm temp.tar jq ' .manifests |= ( - del(.[].annotations) - | unique + unique_by([ .digest, .size, .mediaType ]) | if length != 1 then - error("unexpected number of manifests: " + length) + error("unexpected number of manifests: \(length\)") else . end + | .[0].annotations |= + ( + (if .["io.containerd.image.name"] then .["io.containerd.image.name"] else .["org.opencontainers.image.ref.name"] end) as $ref + | . += { + "org.opencontainers.image.ref.name": $ref + } + ) ) ' temp/index.json > temp/index.json.new mv temp/index.json.new temp/index.json diff --git a/meta.jq b/meta.jq index 12b7a6e..7f51b6d 100644 --- a/meta.jq +++ b/meta.jq @@ -209,11 +209,17 @@ def build_command: # munge the index to what crane wants ("Error: layout contains 5 entries, consider --index") @sh "jq \(" .manifests |= ( - del(.[].annotations) - | unique + unique_by([ .digest, .size, .mediaType ]) | if length != 1 then - error(\"unexpected number of manifests: \" + length) + error(\"unexpected number of manifests: \\(length\\)\") else . end + | .[0].annotations |= + ( + (if .[\"io.containerd.image.name\"] then .[\"io.containerd.image.name\"] else .[\"org.opencontainers.image.ref.name\"] end) as $ref + | . += { + \"org.opencontainers.image.ref.name\": $ref + } + ) ) " | unindent_and_decomment_jq(3)) temp/index.json > temp/index.json.new", "mv temp/index.json.new temp/index.json",