From f8cbf6ea9d4eb0ac68fc78cd5b0ea9a5f395e1f4 Mon Sep 17 00:00:00 2001 From: Vincent Cui Date: Thu, 9 Jul 2026 16:53:25 +0800 Subject: [PATCH] image/manifest: accept OCI media types in Docker schema2 manifests --- image/manifest/docker_schema2_test.go | 6 ++++++ image/manifest/manifest.go | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/image/manifest/docker_schema2_test.go b/image/manifest/docker_schema2_test.go index fcdf689809..b659149282 100644 --- a/image/manifest/docker_schema2_test.go +++ b/image/manifest/docker_schema2_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/opencontainers/go-digest" + imgspecv1 "github.com/opencontainers/image-spec/specs-go/v1" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.podman.io/image/v5/pkg/compression" @@ -34,6 +35,11 @@ func TestSupportedSchema2MediaType(t *testing.T) { {DockerV2ListMediaType, false}, {DockerV2Schema2ForeignLayerMediaType, false}, {DockerV2Schema2ForeignLayerMediaTypeGzip, false}, + {imgspecv1.MediaTypeImageConfig, false}, + {imgspecv1.MediaTypeImageLayer, false}, + {imgspecv1.MediaTypeImageLayerGzip, false}, + {imgspecv1.MediaTypeImageLayerNonDistributable, false}, //nolint:staticcheck // NonDistributable layers are deprecated, but we want to continue to support manipulating pre-existing images. + {imgspecv1.MediaTypeImageLayerNonDistributableGzip, false}, //nolint:staticcheck // NonDistributable layers are deprecated, but we want to continue to support manipulating pre-existing images. {"application/vnd.docker.image.rootfs.foreign.diff.unknown", true}, } for _, d := range data { diff --git a/image/manifest/manifest.go b/image/manifest/manifest.go index 9b891fab1d..283de161e3 100644 --- a/image/manifest/manifest.go +++ b/image/manifest/manifest.go @@ -44,7 +44,12 @@ type NonImageArtifactError = manifest.NonImageArtifactError // SupportedSchema2MediaType checks if the specified string is a supported Docker v2s2 media type. func SupportedSchema2MediaType(m string) error { switch m { - case DockerV2ListMediaType, DockerV2Schema1MediaType, DockerV2Schema1SignedMediaType, DockerV2Schema2ConfigMediaType, DockerV2Schema2ForeignLayerMediaType, DockerV2Schema2ForeignLayerMediaTypeGzip, DockerV2Schema2LayerMediaType, DockerV2Schema2MediaType, DockerV2SchemaLayerMediaTypeUncompressed, DockerV2SchemaLayerMediaTypeZstd: + case DockerV2ListMediaType, DockerV2Schema1MediaType, DockerV2Schema1SignedMediaType, DockerV2Schema2ConfigMediaType, DockerV2Schema2ForeignLayerMediaType, DockerV2Schema2ForeignLayerMediaTypeGzip, DockerV2Schema2LayerMediaType, DockerV2Schema2MediaType, DockerV2SchemaLayerMediaTypeUncompressed, DockerV2SchemaLayerMediaTypeZstd, + imgspecv1.MediaTypeImageConfig, + imgspecv1.MediaTypeImageLayer, + imgspecv1.MediaTypeImageLayerGzip, + imgspecv1.MediaTypeImageLayerNonDistributable, //nolint:staticcheck // NonDistributable layers are deprecated, but we want to continue to support manipulating pre-existing images. + imgspecv1.MediaTypeImageLayerNonDistributableGzip: //nolint:staticcheck // NonDistributable layers are deprecated, but we want to continue to support manipulating pre-existing images. return nil default: return fmt.Errorf("unsupported docker v2s2 media type: %q", m)