Skip to content

Commit

Permalink
Modify index munge for verification
Browse files Browse the repository at this point in the history
Preserves the image.ref.name annotatoon and set it to the first arch tag
  • Loading branch information
LaurentGoderre committed Sep 18, 2024
1 parent c394a5a commit c703c79
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
12 changes: 9 additions & 3 deletions .test/meta-commands/out.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 9 additions & 3 deletions meta.jq
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit c703c79

Please sign in to comment.