Skip to content

Commit 7c18467

Browse files
committed
allow copying and conversion from v2s2 to oci with zstd
Signed-off-by: Luca Guerra <[email protected]>
1 parent e80a235 commit 7c18467

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

image/copy/compression.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ var (
2727
// expectedBaseCompressionFormats is used to check if a blob with a specified media type is compressed
2828
// using the algorithm that the media type says it should be compressed with
2929
expectedBaseCompressionFormats = map[string]*compressiontypes.Algorithm{
30-
imgspecv1.MediaTypeImageLayerGzip: &compression.Gzip,
31-
imgspecv1.MediaTypeImageLayerZstd: &compression.Zstd,
32-
manifest.DockerV2Schema2LayerMediaType: &compression.Gzip,
30+
imgspecv1.MediaTypeImageLayerGzip: &compression.Gzip,
31+
imgspecv1.MediaTypeImageLayerZstd: &compression.Zstd,
32+
manifest.DockerV2Schema2LayerMediaType: &compression.Gzip,
33+
manifest.DockerV2SchemaLayerMediaTypeZstd: &compression.Zstd,
3334
}
3435
)
3536

image/internal/image/docker_schema2.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ func (m *manifestSchema2) convertToManifestOCI1(ctx context.Context, _ *types.Ma
233233
layers[idx].MediaType = imgspecv1.MediaTypeImageLayer
234234
case manifest.DockerV2Schema2LayerMediaType:
235235
layers[idx].MediaType = imgspecv1.MediaTypeImageLayerGzip
236+
case manifest.DockerV2SchemaLayerMediaTypeZstd:
237+
layers[idx].MediaType = imgspecv1.MediaTypeImageLayerZstd
236238
default:
237239
return nil, fmt.Errorf("Unknown media type during manifest conversion: %q", m.m.LayersDescriptors[idx].MediaType)
238240
}

image/internal/image/oci.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ func (m *manifestOCI1) convertToManifestSchema2(_ context.Context, options *type
288288
case imgspecv1.MediaTypeImageLayerGzip:
289289
layers[idx].MediaType = manifest.DockerV2Schema2LayerMediaType
290290
case imgspecv1.MediaTypeImageLayerZstd:
291-
return nil, fmt.Errorf("Error during manifest conversion: %q: zstd compression is not supported for docker images", layers[idx].MediaType)
291+
return nil, fmt.Errorf("Error during manifest conversion: %q: zstd compression is not officially supported for docker images", layers[idx].MediaType)
292292
case ociencspec.MediaTypeLayerEnc, ociencspec.MediaTypeLayerGzipEnc, ociencspec.MediaTypeLayerZstdEnc,
293293
ociencspec.MediaTypeLayerNonDistributableEnc, ociencspec.MediaTypeLayerNonDistributableGzipEnc, ociencspec.MediaTypeLayerNonDistributableZstdEnc:
294294
return nil, fmt.Errorf("during manifest conversion: encrypted layers (%q) are not supported in docker images", layers[idx].MediaType)

image/manifest/manifest.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const (
2727
// DockerV2SchemaLayerMediaTypeUncompressed is the mediaType used for uncompressed layers.
2828
DockerV2SchemaLayerMediaTypeUncompressed = manifest.DockerV2SchemaLayerMediaTypeUncompressed
2929
// DockerV2SchemaLayerMediaTypeZstd is the mediaType used for zstd layers.
30+
// Warning: This mediaType is not officially supported in https://github.com/distribution/distribution/blob/main/docs/content/spec/manifest-v2-2.md but some images may exhibit it. Support is partial.
3031
DockerV2SchemaLayerMediaTypeZstd = manifest.DockerV2SchemaLayerMediaTypeZstd
3132
// DockerV2ListMediaType MIME type represents Docker manifest schema 2 list
3233
DockerV2ListMediaType = manifest.DockerV2ListMediaType

0 commit comments

Comments
 (0)