Skip to content

Commit

Permalink
Merge pull request moby#48546 from thaJeztah/carry_48533
Browse files Browse the repository at this point in the history
Update download-frozen-image-v2.sh added OCI v1 support (carry 48533)
  • Loading branch information
tianon authored Sep 26, 2024
2 parents b9cd744 + 98d74e3 commit 62120a7
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions contrib/download-frozen-image-v2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ handle_single_manifest_v2() {
fi

case "$layerMediaType" in
application/vnd.docker.image.rootfs.diff.tar.gzip)
application/vnd.oci.image.layer.v1.tar+gzip | application/vnd.docker.image.rootfs.diff.tar.gzip)
local layerTar="$layerId/layer.tar"
layerFiles=("${layerFiles[@]}" "$layerTar")
# TODO figure out why "-C -" doesn't work here
Expand Down Expand Up @@ -203,10 +203,10 @@ handle_single_manifest_v2() {

local manifestJsonEntry
manifestJsonEntry="$(
echo '{}' | jq --raw-output '. + {
echo '{}' | jq --raw-output --compact-output '. + {
Config: "'"$configFile"'",
RepoTags: ["'"${image#library\/}:$tag"'"],
Layers: '"$(echo '[]' | jq --raw-output ".$(for layerFile in "${layerFiles[@]}"; do echo " + [ \"$layerFile\" ]"; done)")"'
Layers: '"$(echo '[]' | jq --raw-output --compact-output ".$(for layerFile in "${layerFiles[@]}"; do echo " + [ \"$layerFile\" ]"; done)")"'
}'
)"
manifestJsonEntries=("${manifestJsonEntries[@]}" "$manifestJsonEntry")
Expand Down Expand Up @@ -298,6 +298,8 @@ while [ $# -gt 0 ]; do
manifestJson="$(
curl -fsSL \
-H "Authorization: Bearer $token" \
-H 'Accept: application/vnd.oci.image.manifest.v1+json' \
-H 'Accept: application/vnd.oci.image.index.v1+json' \
-H 'Accept: application/vnd.docker.distribution.manifest.v2+json' \
-H 'Accept: application/vnd.docker.distribution.manifest.list.v2+json' \
-H 'Accept: application/vnd.docker.distribution.manifest.v1+json' \
Expand All @@ -317,10 +319,10 @@ while [ $# -gt 0 ]; do
mediaType="$(echo "$manifestJson" | jq --raw-output '.mediaType')"

case "$mediaType" in
application/vnd.docker.distribution.manifest.v2+json)
application/vnd.oci.image.manifest.v1+json | application/vnd.docker.distribution.manifest.v2+json)
handle_single_manifest_v2 "$manifestJson"
;;
application/vnd.docker.distribution.manifest.list.v2+json)
application/vnd.oci.image.index.v1+json | application/vnd.docker.distribution.manifest.list.v2+json)
layersFs="$(echo "$manifestJson" | jq --raw-output --compact-output '.manifests[]')"
IFS="$newlineIFS"
mapfile -t layers <<< "$layersFs"
Expand All @@ -340,6 +342,8 @@ while [ $# -gt 0 ]; do
submanifestJson="$(
curl -fsSL \
-H "Authorization: Bearer $token" \
-H 'Accept: application/vnd.oci.image.manifest.v1+json' \
-H 'Accept: application/vnd.oci.image.index.v1+json' \
-H 'Accept: application/vnd.docker.distribution.manifest.v2+json' \
-H 'Accept: application/vnd.docker.distribution.manifest.list.v2+json' \
-H 'Accept: application/vnd.docker.distribution.manifest.v1+json' \
Expand Down

0 comments on commit 62120a7

Please sign in to comment.