From 432c134cbd82e8c43382d83ceaefa6fa70d6c85f Mon Sep 17 00:00:00 2001 From: Stephen J Day Date: Fri, 26 Aug 2016 15:54:14 -0700 Subject: [PATCH] serialization: remove extra "hierarchy" from mediatypes The fact that we are serializing is implied. This PR removes the extra bits in the media type that only serve to confuse and waste bytes. The new media types better reflect the reality for the usage of each type and how they relate. This must be followed up by a split of the serialization document, but this change _should_ be applied first. This change is backwards incompatible with previous versions of the OCI specification. Since we are before 1.0, this is acceptable. Signed-off-by: Stephen J Day --- cmd/oci-image-tool/validate.go | 2 +- image-layout.md | 4 ++-- image/config.go | 2 +- image/manifest.go | 2 +- img/media-types.dot | 4 ++-- manifest.md | 8 ++++---- media-types.md | 6 +++--- schema/config_test.go | 2 +- .../manifest_backwards_compatibility_test.go | 4 ++-- schema/manifest_test.go | 8 ++++---- schema/schema.go | 18 +++++++++--------- serialization.md | 4 ++-- specs-go/v1/mediatype.go | 4 ++-- 13 files changed, 34 insertions(+), 34 deletions(-) diff --git a/cmd/oci-image-tool/validate.go b/cmd/oci-image-tool/validate.go index c53ba7959..c2b42e2ef 100644 --- a/cmd/oci-image-tool/validate.go +++ b/cmd/oci-image-tool/validate.go @@ -142,7 +142,7 @@ func (v *validateCmd) validatePath(name string) error { return schema.MediaTypeManifestList.Validate(f) case typeConfig: - return schema.MediaTypeImageSerializationConfig.Validate(f) + return schema.MediaTypeImageConfig.Validate(f) } return fmt.Errorf("type %q unimplemented", typ) diff --git a/image-layout.md b/image-layout.md index 4df551f9c..51d057187 100644 --- a/image-layout.md +++ b/image-layout.md @@ -78,13 +78,13 @@ $ cat ./blobs/sha256-afff3924849e458c5ef237db5f89539274d5e609db5db935ed3959c90f1 "schemaVersion": 2, "mediaType": "application/vnd.oci.image.manifest.v1+json", "config": [ - "mediaType": "application/vnd.oci.image.serialization.config.v1+json", + "mediaType": "application/vnd.oci.image.config.v1+json", "size": 7023, "digest": "sha256:5b0bcabd1ed22e9fb1310cf6c2dec7cdef19f0ad69efa1f392e94a4333501270" }, "layers": [ { - "mediaType": "application/vnd.oci.image.serialization.rootfs.tar.gzip", + "mediaType": "application/vnd.oci.image.layer.tar+gzip", "size": 32654, "digest": "sha256:e692418e4cbaf90ca69d05a66403747baa33ee08806650b51fab815ad7fc331f" }, diff --git a/image/config.go b/image/config.go index 994d2ffd7..922f161c3 100644 --- a/image/config.go +++ b/image/config.go @@ -67,7 +67,7 @@ func findConfig(w walker, d *descriptor) (*config, error) { return errors.Wrapf(err, "%s: error reading config", path) } - if err := schema.MediaTypeImageSerializationConfig.Validate(bytes.NewReader(buf)); err != nil { + if err := schema.MediaTypeImageConfig.Validate(bytes.NewReader(buf)); err != nil { return errors.Wrapf(err, "%s: config validation failed", path) } diff --git a/image/manifest.go b/image/manifest.go index 13550ea51..49a9fe983 100644 --- a/image/manifest.go +++ b/image/manifest.go @@ -97,7 +97,7 @@ func (m *manifest) validate(w walker) error { func (m *manifest) unpack(w walker, dest string) error { for _, d := range m.Layers { - if d.MediaType != string(schema.MediaTypeImageSerialization) { + if d.MediaType != string(schema.MediaTypeImageConfig) { continue } diff --git a/img/media-types.dot b/img/media-types.dot index ee0dd8463..aa839bd40 100644 --- a/img/media-types.dot +++ b/img/media-types.dot @@ -2,8 +2,8 @@ digraph G { { manifestList [shape=note, label="Manifest list\n<>\napplication/vnd.oci.image.manifest.list.v1+json"] manifest [shape=note, label="Image manifest\napplication/vnd.oci.image.manifest.v1+json"] - config [shape=note, label="Image JSON\napplication/vnd.oci.image.serialization.config.v1+json"] - layer [shape=note, label="Layer tar+gzip\napplication/vnd.oci.image.serialization.rootfs.tar.gzip"] + config [shape=note, label="Image JSON\napplication/vnd.oci.image.config.v1+json"] + layer [shape=note, label="Layer tar+gzip\napplication/vnd.oci.image.layer.tar+gzip"] combined [shape=note, label="Combined image JSON and filesystem changesets\n<>\napplication/vnd.oci.image.serialization.combined.v1+json"] } diff --git a/manifest.md b/manifest.md index 42cfe0a3b..70f829ea6 100644 --- a/manifest.md +++ b/manifest.md @@ -158,23 +158,23 @@ Unlike the [Manifest List](#manifest-list), which contains information about a s "schemaVersion": 2, "mediaType": "application/vnd.oci.image.manifest.v1+json", "config": { - "mediaType": "application/vnd.oci.image.serialization.config.v1+json", + "mediaType": "application/vnd.oci.image.config.v1+json", "size": 7023, "digest": "sha256:b5b2b2c507a0944348e0303114d8d93aaaa081732b86451d9bce1f432a537bc7" }, "layers": [ { - "mediaType": "application/vnd.oci.image.serialization.rootfs.tar.gzip", + "mediaType": "application/vnd.oci.image.layer.tar+gzip", "size": 32654, "digest": "sha256:e692418e4cbaf90ca69d05a66403747baa33ee08806650b51fab815ad7fc331f" }, { - "mediaType": "application/vnd.oci.image.serialization.rootfs.tar.gzip", + "mediaType": "application/vnd.oci.image.layer.tar+gzip", "size": 16724, "digest": "sha256:3c3a4604a545cdc127456d94e421cd355bca5b528f4a9c1905b15da2eb4a4c6b" }, { - "mediaType": "application/vnd.oci.image.serialization.rootfs.tar.gzip", + "mediaType": "application/vnd.oci.image.layer.tar+gzip", "size": 73109, "digest": "sha256:ec4b8955958665577945c89419d1af06b5f7636b4ac3da7f12184802ad867736" } diff --git a/media-types.md b/media-types.md index 57f7f59a5..f97f77328 100644 --- a/media-types.md +++ b/media-types.md @@ -5,8 +5,8 @@ The following `mediaType` MIME types are used by the formats described here, and - `application/vnd.oci.descriptor.v1+json`: [Content Descriptor](descriptor.md) - `application/vnd.oci.image.manifest.list.v1+json`: [Manifest list](manifest.md#manifest-list) - `application/vnd.oci.image.manifest.v1+json`: [Image manifest format](manifest.md#image-manifest) -- `application/vnd.oci.image.serialization.rootfs.tar.gzip`: ["Layer", as a gzipped tar archive](serialization.md#creating-an-image-filesystem-changeset) -- `application/vnd.oci.image.serialization.config.v1+json`: [Container config JSON](serialization.md#image-json-description) +- `application/vnd.oci.image.layer.tar+gzip`: ["Layer", as a gzipped tar archive](serialization.md#creating-an-image-filesystem-changeset) +- `application/vnd.oci.image.config.v1+json`: [Container config JSON](serialization.md#image-json-description) ## Compatibility Matrix @@ -32,7 +32,7 @@ This section shows where the OCI Image Specification is compatible with formats - [application/vnd.docker.image.rootfs.diff.tar.gzip](https://github.com/docker/docker/blob/master/image/spec/v1.md#creating-an-image-filesystem-changeset) -### application/vnd.oci.image.serialization.config.v1+json +### application/vnd.oci.image.config.v1+json **Similar/related schema** diff --git a/schema/config_test.go b/schema/config_test.go index a98f91811..27c14875c 100644 --- a/schema/config_test.go +++ b/schema/config_test.go @@ -156,7 +156,7 @@ func TestConfig(t *testing.T) { }, } { r := strings.NewReader(tt.config) - err := schema.MediaTypeImageSerializationConfig.Validate(r) + err := schema.MediaTypeImageConfig.Validate(r) if got := err != nil; tt.fail != got { t.Errorf("test %d: expected validation failure %t but got %t, err %v", i, tt.fail, got, err) diff --git a/schema/manifest_backwards_compatibility_test.go b/schema/manifest_backwards_compatibility_test.go index 531cc77a6..89e18665a 100644 --- a/schema/manifest_backwards_compatibility_test.go +++ b/schema/manifest_backwards_compatibility_test.go @@ -28,7 +28,7 @@ var compatMap = map[string]string{ "application/vnd.docker.distribution.manifest.list.v2+json": "application/vnd.oci.image.manifest.list.v1+json", "application/vnd.docker.distribution.manifest.v2+json": "application/vnd.oci.image.manifest.v1+json", "application/vnd.docker.image.rootfs.diff.tar.gzip": "application/vnd.oci.image.rootfs.tar.gzip", - "application/vnd.docker.container.image.v1+json": "application/vnd.oci.image.serialization.config.v1+json", + "application/vnd.docker.container.image.v1+json": "application/vnd.oci.image.config.v1+json", } // convertFormats converts Docker v2.2 image format JSON documents to OCI @@ -220,7 +220,7 @@ func TestBackwardsCompatibilityConfig(t *testing.T) { manifest := convertFormats(tt.manifest) r := strings.NewReader(manifest) - err := schema.MediaTypeImageSerializationConfig.Validate(r) + err := schema.MediaTypeImageConfig.Validate(r) if got := err != nil; tt.fail != got { t.Errorf("test %d: expected validation failure %t but got %t, err %v", i, tt.fail, got, err) diff --git a/schema/manifest_test.go b/schema/manifest_test.go index ad82bf7ad..a4da16e97 100644 --- a/schema/manifest_test.go +++ b/schema/manifest_test.go @@ -66,7 +66,7 @@ func TestManifest(t *testing.T) { }, "layers": [ { - "mediaType": "application/vnd.oci.image.serialization.rootfs.tar.gzip", + "mediaType": "application/vnd.oci.image.layer.tar+gzip", "size": "675598" } ] @@ -88,17 +88,17 @@ func TestManifest(t *testing.T) { }, "layers": [ { - "mediaType": "application/vnd.oci.image.serialization.rootfs.tar.gzip", + "mediaType": "application/vnd.oci.image.layer.tar+gzip", "size": 675598, "digest": "sha256:9d3dd9504c685a304985025df4ed0283e47ac9ffa9bd0326fddf4d59513f0827" }, { - "mediaType": "application/vnd.oci.image.serialization.rootfs.tar.gzip", + "mediaType": "application/vnd.oci.image.layer.tar+gzip", "size": 156, "digest": "sha256:2b689805fbd00b2db1df73fae47562faac1a626d5f61744bfe29946ecff5d73d" }, { - "mediaType": "application/vnd.oci.image.serialization.rootfs.tar.gzip", + "mediaType": "application/vnd.oci.image.layer.tar+gzip", "size": 148, "digest": "sha256:c57089565e894899735d458f0fd4bb17a0f1e0df8d72da392b85c9b35ee777cd" } diff --git a/schema/schema.go b/schema/schema.go index b91713923..a8bd59211 100644 --- a/schema/schema.go +++ b/schema/schema.go @@ -18,11 +18,11 @@ import "net/http" // Media types for the OCI image formats const ( - MediaTypeDescriptor Validator = `application/vnd.oci.descriptor.v1+json` - MediaTypeManifest Validator = `application/vnd.oci.image.manifest.v1+json` - MediaTypeManifestList Validator = `application/vnd.oci.image.manifest.list.v1+json` - MediaTypeImageSerialization unimplemented = `application/vnd.oci.image.serialization.rootfs.tar.gzip` - MediaTypeImageSerializationConfig Validator = `application/vnd.oci.image.serialization.config.v1+json` + MediaTypeDescriptor Validator = `application/vnd.oci.descriptor.v1+json` + MediaTypeManifest Validator = `application/vnd.oci.image.manifest.v1+json` + MediaTypeManifestList Validator = `application/vnd.oci.image.manifest.list.v1+json` + MediaTypeImageConfig Validator = `application/vnd.oci.image.config.v1+json` + MediaTypeImageLayer unimplemented = `application/vnd.oci.image.layer.tar+gzip` ) var ( @@ -32,10 +32,10 @@ var ( // specs maps OCI schema media types to schema files. specs = map[Validator]string{ - MediaTypeDescriptor: "content-descriptor.json", - MediaTypeManifest: "image-manifest-schema.json", - MediaTypeManifestList: "manifest-list-schema.json", - MediaTypeImageSerializationConfig: "config-schema.json", + MediaTypeDescriptor: "content-descriptor.json", + MediaTypeManifest: "image-manifest-schema.json", + MediaTypeManifestList: "manifest-list-schema.json", + MediaTypeImageConfig: "config-schema.json", } ) diff --git a/serialization.md b/serialization.md index a68fd1b3b..789d02ac8 100644 --- a/serialization.md +++ b/serialization.md @@ -38,7 +38,7 @@ This specification uses the following terms:
A layer DiffID is a SHA256 digest over the layer's uncompressed tar archive and serialized in the descriptor digest format, e.g., sha256:a9561eb1b190625c9adb5a9513e72c4dedafc1cb2d4c5236c9a6957ec7dfd5a9. Layers must be packed and unpacked reproducibly to avoid changing the layer ID, for example by using tar-split to save the tar headers. - NOTE: the DiffID is different than the digest in the manifest list because the manifest digest is taken over the gzipped layer for `application/vnd.oci.image.serialization.rootfs.tar.gzip` types. + NOTE: the DiffID is different than the digest in the manifest list because the manifest digest is taken over the gzipped layer for `application/vnd.oci.image.layer.tar+gzip` types.
Layer ChainID @@ -86,7 +86,7 @@ This specification uses the following terms: Here is an example image JSON file: -```json,title=Image%20JSON&mediatype=application/vnd.oci.image.serialization.config.v1%2Bjson +```json,title=Image%20JSON&mediatype=application/vnd.oci.image.config.v1%2Bjson { "created": "2015-10-31T22:22:56.015925234Z", "author": "Alyssa P. Hacker ", diff --git a/specs-go/v1/mediatype.go b/specs-go/v1/mediatype.go index d5f128fc8..80971d0ea 100644 --- a/specs-go/v1/mediatype.go +++ b/specs-go/v1/mediatype.go @@ -25,8 +25,8 @@ const ( MediaTypeImageManifestList = "application/vnd.oci.image.manifest.list.v1+json" // MediaTypeImageSerialization is the mediaType used for layers referenced by the manifest. - MediaTypeImageSerialization = "application/vnd.oci.image.serialization.rootfs.tar.gzip" + MediaTypeImageSerialization = "application/vnd.oci.image.layer.tar+gzip" // MediaTypeImageSerializationConfig specifies the mediaType for the image configuration. - MediaTypeImageSerializationConfig = "application/vnd.oci.image.serialization.config.v1+json" + MediaTypeImageSerializationConfig = "application/vnd.oci.image.config.v1+json" )