diff --git a/src/client.rs b/src/client.rs index 40d984e3..560de302 100644 --- a/src/client.rs +++ b/src/client.rs @@ -993,7 +993,7 @@ impl Client { /// Pushes the manifest for a specified image /// /// Returns pullable manifest URL - async fn push_manifest(&self, image: &Reference, manifest: &OciManifest) -> Result { + pub async fn push_manifest(&self, image: &Reference, manifest: &OciManifest) -> Result { let url = self.to_v2_manifest_url(image); let mut headers = HeaderMap::new(); @@ -1412,22 +1412,17 @@ pub fn current_platform_resolver(manifests: &[ImageIndexEntry]) -> Option), } -impl Default for ClientProtocol { - fn default() -> Self { - ClientProtocol::Https - } -} - impl ClientProtocol { fn scheme_for(&self, registry: &str) -> &str { match self { @@ -1468,7 +1463,6 @@ impl TryFrom<&HeaderValue> for BearerChallenge { None } }) - .into_iter() .next() .ok_or_else(|| "Cannot find Bearer challenge".to_string()) } diff --git a/src/config.rs b/src/config.rs index 92e69465..7b503c73 100644 --- a/src/config.rs +++ b/src/config.rs @@ -133,8 +133,7 @@ struct Empty {} /// Helper to deserialize a `map[string]struct{}` of golang fn hashset_from_str<'de, D: Deserializer<'de>>(d: D) -> Result, D::Error> { let res = >::deserialize(d)? - .into_iter() - .map(|(k, _)| k) + .into_keys() .collect(); Ok(res) } diff --git a/src/manifest.rs b/src/manifest.rs index 5464a940..06b71119 100644 --- a/src/manifest.rs +++ b/src/manifest.rs @@ -53,8 +53,13 @@ impl OciManifest { /// Returns the appropriate content-type for each variant. pub fn content_type(&self) -> &str { match self { - OciManifest::Image(_) => OCI_IMAGE_MEDIA_TYPE, - OciManifest::ImageIndex(_) => IMAGE_MANIFEST_LIST_MEDIA_TYPE, + OciManifest::Image(image) => { + image.media_type.as_deref().unwrap_or(OCI_IMAGE_MEDIA_TYPE) + } + OciManifest::ImageIndex(image) => image + .media_type + .as_deref() + .unwrap_or(IMAGE_MANIFEST_LIST_MEDIA_TYPE), } } } @@ -452,6 +457,7 @@ impl std::fmt::Display for Platform { #[cfg(test)] mod test { use super::*; + const TEST_MANIFEST: &str = r#"{ "schemaVersion": 2, "mediaType": "application/vnd.docker.distribution.manifest.v2+json",