From c3a73dc4242d8ca821f20bba64fa432e91eeb56c Mon Sep 17 00:00:00 2001
From: Valentin Rothberg <rothberg@redhat.com>
Date: Fri, 23 Aug 2019 10:39:07 +0200
Subject: [PATCH] zstd: add constants to specs-go/v1

Add go constants for the zstd MIME types to make them usable by
consumers of the go package.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
---
 schema/validator.go      | 4 +++-
 specs-go/v1/mediatype.go | 9 +++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/schema/validator.go b/schema/validator.go
index 029217c3..545ade22 100644
--- a/schema/validator.go
+++ b/schema/validator.go
@@ -117,8 +117,10 @@ func validateManifest(r io.Reader) error {
 	for _, layer := range header.Layers {
 		if layer.MediaType != string(v1.MediaTypeImageLayer) &&
 			layer.MediaType != string(v1.MediaTypeImageLayerGzip) &&
+			layer.MediaType != string(v1.MediaTypeImageLayerZstd) &&
 			layer.MediaType != string(v1.MediaTypeImageLayerNonDistributable) &&
-			layer.MediaType != string(v1.MediaTypeImageLayerNonDistributableGzip) {
+			layer.MediaType != string(v1.MediaTypeImageLayerNonDistributableGzip) &&
+			layer.MediaType != string(v1.MediaTypeImageLayerNonDistributableZstd) {
 			fmt.Printf("warning: layer %s has an unknown media type: %s\n", layer.Digest, layer.MediaType)
 		}
 	}
diff --git a/specs-go/v1/mediatype.go b/specs-go/v1/mediatype.go
index bad7bb97..4f35ac13 100644
--- a/specs-go/v1/mediatype.go
+++ b/specs-go/v1/mediatype.go
@@ -34,6 +34,10 @@ const (
 	// referenced by the manifest.
 	MediaTypeImageLayerGzip = "application/vnd.oci.image.layer.v1.tar+gzip"
 
+	// MediaTypeImageLayerZstd is the media type used for zstd compressed
+	// layers referenced by the manifest.
+	MediaTypeImageLayerZstd = "application/vnd.oci.image.layer.v1.tar+zstd"
+
 	// MediaTypeImageLayerNonDistributable is the media type for layers referenced by
 	// the manifest but with distribution restrictions.
 	MediaTypeImageLayerNonDistributable = "application/vnd.oci.image.layer.nondistributable.v1.tar"
@@ -43,6 +47,11 @@ const (
 	// restrictions.
 	MediaTypeImageLayerNonDistributableGzip = "application/vnd.oci.image.layer.nondistributable.v1.tar+gzip"
 
+	// MediaTypeImageLayerNonDistributableZstd is the media type for zstd
+	// compressed layers referenced by the manifest but with distribution
+	// restrictions.
+	MediaTypeImageLayerNonDistributableZstd = "application/vnd.oci.image.layer.nondistributable.v1.tar+zstd"
+
 	// MediaTypeImageConfig specifies the media type for the image configuration.
 	MediaTypeImageConfig = "application/vnd.oci.image.config.v1+json"
 )
