Skip to content

Commit

Permalink
Add support for OCI Image Index
Browse files Browse the repository at this point in the history
OCI Image Index (https://github.com/opencontainers/image-spec/blob/v1.0.1/image-index.md)
is similar to vnd.docker.distribution.manifest.list.v2

This revives #244 originally created by @luizribeiro

A testing client could pull koenkk/zigbee2mqtt:latest with this change.

Fixes #243
  • Loading branch information
chantra committed Feb 10, 2024
1 parent 1d779db commit 035f1a5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/mediatypes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ pub enum MediaTypes {
#[strum(serialize = "application/vnd.oci.image.manifest.v1+json")]
#[strum(props(Sub = "vnd.oci.image.manifest.v1+json"))]
OciImageManifest,
// OCI Image index
#[strum(serialize = "application/vnd.oci.image.index.v1+json")]
#[strum(props(Sub = "vnd.oci.image.index.v1+json"))]
OciImageIndexV1,
/// Generic JSON
#[strum(serialize = "application/json")]
#[strum(props(Sub = "json"))]
Expand All @@ -60,6 +64,7 @@ impl MediaTypes {
("vnd.docker.image.rootfs.diff.tar.gzip", _) => Ok(MediaTypes::ImageLayerTgz),
("vnd.docker.container.image.v1", "json") => Ok(MediaTypes::ContainerConfigV1),
("vnd.oci.image.manifest.v1", "json") => Ok(MediaTypes::OciImageManifest),
("vnd.oci.image.index.v1", "json") => Ok(MediaTypes::OciImageIndexV1),
_ => Err(crate::Error::UnknownMimeType(mtype.clone())),
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/v2/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ impl Config {
(MediaTypes::ManifestV2S1Signed, Some(0.4)),
(MediaTypes::ManifestList, Some(0.5)),
(MediaTypes::OciImageManifest, Some(0.5)),
(MediaTypes::OciImageIndexV1, Some(0.5)),
],
// GCR incorrectly parses `q` parameters, so we use special Accept for it.
// Bug: https://issuetracker.google.com/issues/159827510.
Expand All @@ -124,6 +125,7 @@ impl Config {
(MediaTypes::ManifestV2S1Signed, None),
(MediaTypes::ManifestList, None),
(MediaTypes::OciImageManifest, None),
(MediaTypes::OciImageIndexV1, None),
],
},
};
Expand Down
2 changes: 1 addition & 1 deletion src/v2/manifest/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl Client {
content_digest,
))
}
mediatypes::MediaTypes::ManifestList => Ok((
mediatypes::MediaTypes::ManifestList | mediatypes::MediaTypes::OciImageIndexV1 => Ok((
res.json::<ManifestList>().await.map(Manifest::ML)?,
content_digest,
)),
Expand Down

0 comments on commit 035f1a5

Please sign in to comment.