From c43e4c129edf7fbc31feb8443aa2e3d56316279b Mon Sep 17 00:00:00 2001 From: "Wang, Arron" Date: Mon, 13 Mar 2023 17:08:18 +0800 Subject: [PATCH] client: Fix failed to pull ubuntu image from docker.io Manifests list feature in oci-distribution is already implemented, default image in docker.io like busybox use IMAGE_MANIFEST_LIST_MEDIA_TYPE, but ubuntu image use OCI_IMAGE_INDEX_MEDIA_TYPE. Fixes: #27 Signed-off-by: Wang, Arron --- src/client.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/client.rs b/src/client.rs index 84e1dda6..6c55be15 100644 --- a/src/client.rs +++ b/src/client.rs @@ -696,6 +696,7 @@ impl Client { if media_type != IMAGE_MANIFEST_MEDIA_TYPE && media_type != OCI_IMAGE_MEDIA_TYPE && media_type != IMAGE_MANIFEST_LIST_MEDIA_TYPE + && media_type != OCI_IMAGE_INDEX_MEDIA_TYPE { return Err(OciDistributionError::UnsupportedMediaTypeError(media_type)); } @@ -1521,6 +1522,7 @@ mod test { ]; const GHCR_IO_IMAGE: &str = "ghcr.io/krustlet/oci-distribution/hello-wasm:v1"; const DOCKER_IO_IMAGE: &str = "docker.io/library/hello-world@sha256:37a0b92b08d4919615c3ee023f7ddb068d12b8387475d64c622ac30f45c29c51"; + const DOCKER_IO_UBUNTU: &str = "docker.io/library/ubuntu"; const HTPASSWD: &str = "testuser:$2y$05$8/q2bfRcX74EuxGf0qOcSuhWDQJXrgWiy6Fi73/JM2tKC66qSrLve"; const HTPASSWD_USERNAME: &str = "testuser"; const HTPASSWD_PASSWORD: &str = "testpassword"; @@ -2375,6 +2377,20 @@ mod test { assert_eq!(manifest.config.media_type, manifest::WASM_CONFIG_MEDIA_TYPE); } + #[tokio::test] + async fn test_pull_docker_ubuntu() { + let reference = Reference::try_from(DOCKER_IO_UBUNTU).expect("failed to parse reference"); + let mut c = Client::default(); + assert!(c + .pull( + &reference, + &RegistryAuth::Anonymous, + vec![IMAGE_LAYER_GZIP_MEDIA_TYPE], + ) + .await + .is_ok()); + } + #[tokio::test] #[ignore] async fn test_roundtrip_multiple_layers() {