Skip to content

Commit

Permalink
oci: allow zstd for Docker images
Browse files Browse the repository at this point in the history
Allow to use the zstd compression for docker images now that Docker
supports it: moby/moby#41759

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
  • Loading branch information
giuseppe committed Sep 17, 2021
1 parent 1bf5c4a commit 0bedb77
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion image/oci.go
Expand Up @@ -216,7 +216,7 @@ func (m *manifestOCI1) convertToManifestSchema2(_ context.Context, _ *types.Mani
case imgspecv1.MediaTypeImageLayerGzip:
layers[idx].MediaType = manifest.DockerV2Schema2LayerMediaType
case imgspecv1.MediaTypeImageLayerZstd:
return nil, fmt.Errorf("Error during manifest conversion: %q: zstd compression is not supported for docker images", layers[idx].MediaType)
layers[idx].MediaType = manifest.DockerV2Schema2LayerMediaTypeZstd
default:
return nil, fmt.Errorf("Unknown media type during manifest conversion: %q", layers[idx].MediaType)
}
Expand Down
2 changes: 1 addition & 1 deletion image/oci_test.go
Expand Up @@ -486,7 +486,7 @@ func TestConvertToManifestSchema2AllMediaTypes(t *testing.T) {
_, err := original.UpdatedImage(context.Background(), types.ManifestUpdateOptions{
ManifestMIMEType: manifest.DockerV2Schema2MediaType,
})
require.Error(t, err) // zstd compression is not supported for docker images
require.NoError(t, err)
}

func TestConvertToV2S2WithInvalidMIMEType(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions manifest/manifest.go
Expand Up @@ -24,6 +24,8 @@ const (
DockerV2Schema2ConfigMediaType = "application/vnd.docker.container.image.v1+json"
// DockerV2Schema2LayerMediaType is the MIME type used for schema 2 layers.
DockerV2Schema2LayerMediaType = "application/vnd.docker.image.rootfs.diff.tar.gzip"
// DockerV2Schema2LayerMediaTypeZstd is the MIME type used for schema 2 layers that use the zstd compression.
DockerV2Schema2LayerMediaTypeZstd = "application/vnd.docker.image.rootfs.diff.tar.zst"
// DockerV2SchemaLayerMediaTypeUncompressed is the mediaType used for uncompressed layers.
DockerV2SchemaLayerMediaTypeUncompressed = "application/vnd.docker.image.rootfs.diff.tar"
// DockerV2ListMediaType MIME type represents Docker manifest schema 2 list
Expand Down

0 comments on commit 0bedb77

Please sign in to comment.