From f1f29a970711dd88349e8da7214987d631c9d2f4 Mon Sep 17 00:00:00 2001 From: Aaron Lehmann Date: Mon, 1 Apr 2024 13:24:15 -0700 Subject: [PATCH] Support zstd compression in image commit Without this change, specifying `Compression: imagebuildah.Zstd` in `imagebuildah`'s `BuildOptions fails, so it is not possible to push cache to a registry with zstd compression. https://github.com/opencontainers/image-spec/blob/main/media-types.md defines a media type for zstd-compressed layers, so I don't think the comment about lack of a defined media type is still applicable. Signed-off-by: Aaron Lehmann --- image.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/image.go b/image.go index a26153b9b6f..20b2a8e64b3 100644 --- a/image.go +++ b/image.go @@ -155,9 +155,9 @@ func computeLayerMIMEType(what string, layerCompression archive.Compression) (om // how to decompress them, we can't try to compress layers with xz. return "", "", errors.New("media type for xz-compressed layers is not defined") case archive.Zstd: - // Until the image specs define a media type for zstd-compressed layers, even if we know - // how to decompress them, we can't try to compress layers with zstd. - return "", "", errors.New("media type for zstd-compressed layers is not defined") + omediaType = v1.MediaTypeImageLayerZstd + dmediaType = "application/vnd.docker.image.rootfs.diff.tar.zstd" + logrus.Debugf("compressing %s with zstd", what) default: logrus.Debugf("compressing %s with unknown compressor(?)", what) }