Skip to content

Commit

Permalink
client: Fix failed to pull ubuntu image from docker.io
Browse files Browse the repository at this point in the history
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 <arron.wang@intel.com>
  • Loading branch information
arronwy committed Mar 13, 2023
1 parent 55721aa commit c43e4c1
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit c43e4c1

Please sign in to comment.