Skip to content
Open
Changes from all commits
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
19 changes: 15 additions & 4 deletions src/buildstream_plugins/sources/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#

"""
docker - stage files from Docker images
docker - stage files from Docker/OCI images
=======================================

**Usage:**
Expand Down Expand Up @@ -282,6 +282,8 @@ def manifest(
accept_types = [
"application/vnd.docker.distribution.manifest.v2+json",
"application/vnd.docker.distribution.manifest.list.v2+json",
"application/vnd.oci.image.index.v1+json",
"application/vnd.oci.image.manifest.v1+json",
]

manifest_url = urljoin(image_path, "manifests", urllib.parse.quote(reference))
Expand Down Expand Up @@ -319,7 +321,10 @@ def manifest(
manifest=response.text,
)

if manifest["mediaType"] == "application/vnd.docker.distribution.manifest.list.v2+json":
if manifest["mediaType"] in (
"application/vnd.docker.distribution.manifest.list.v2+json",
"application/vnd.oci.image.index.v1+json",
):
# This is a "fat manifest", we need to narrow down to a specific
# architecture.
for sub in manifest["manifests"]:
Expand All @@ -335,7 +340,10 @@ def manifest(
"No images found for architecture {}, OS {}".format(architecture, os_),
manifest=response.text,
)
if manifest["mediaType"] == "application/vnd.docker.distribution.manifest.v2+json":
elif manifest["mediaType"] in (
"application/vnd.docker.distribution.manifest.v2+json",
"application/vnd.oci.image.manifest.v1+json",
):
return response.text, our_digest
else:
raise DockerManifestError(
Expand Down Expand Up @@ -576,7 +584,10 @@ def fetch(self):
raise SourceError(e) from e

for layer in manifest["layers"]:
if layer["mediaType"] != "application/vnd.docker.image.rootfs.diff.tar.gzip":
if layer["mediaType"] not in (
"application/vnd.docker.image.rootfs.diff.tar.gzip",
"application/vnd.oci.image.layer.v1.tar+gzip",
):
raise SourceError("Unsupported layer type: {}".format(layer["mediaType"]))

layer_digest = layer["digest"]
Expand Down