Skip to content

Commit 23c4647

Browse files
committed
Define image manifest artifactType and guidance
Signed-off-by: Brandon Mitchell <[email protected]>
1 parent 48fd074 commit 23c4647

File tree

6 files changed

+148
-3
lines changed

6 files changed

+148
-3
lines changed

manifest.md

Lines changed: 90 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ Unlike the [image index](image-index.md), which contains information about a set
2626
When used, this field MUST contain the media type `application/vnd.oci.image.manifest.v1+json`.
2727
This field usage differs from the [descriptor](descriptor.md#properties) use of `mediaType`.
2828

29+
- **`artifactType`** *string*
30+
31+
This OPTIONAL property contains the type of an artifact when the manifest is used for an artifact.
32+
This MUST be set when `config.mediaType` is set to the [scratch value](#example-of-a-scratch-config-or-layer-descriptor).
33+
If defined, the value MUST comply with [RFC 6838][rfc6838], including the [naming requirements in its section 4.2][rfc6838-s4.2], and MAY be registered with [IANA][iana].
34+
2935
- **`config`** *[descriptor](descriptor.md)*
3036

3137
This REQUIRED property references a configuration object for a container, by digest.
@@ -38,7 +44,8 @@ Unlike the [image index](image-index.md), which contains information about a set
3844

3945
- [`application/vnd.oci.image.config.v1+json`](config.md)
4046

41-
Manifests concerned with portability SHOULD use one of the above media types.
47+
Manifests for container images concerned with portability SHOULD use one of the above media types.
48+
Manifests for artifacts concerned with portability SHOULD use `config.mediaType` as described in [Guidelines for Artifact Usage](#guidelines-for-artifact-usage).
4249

4350
If the manifest uses a different media type than the above, it MUST comply with [RFC 6838][rfc6838], including the [naming requirements in its section 4.2][rfc6838-s4.2], and MAY be registered with [IANA][iana].
4451

@@ -78,6 +85,8 @@ Unlike the [image index](image-index.md), which contains information about a set
7885

7986
If the manifest uses a different media type than the above, it MUST comply with [RFC 6838][rfc6838], including the [naming requirements in its section 4.2][rfc6838-s4.2], and MAY be registered with [IANA][iana].
8087

88+
See [Guidelines for Artifact Usage](#guidelines-for-artifact-usage) for other uses of the `layers`.
89+
8190
- **`subject`** *[descriptor](descriptor.md)*
8291

8392
This OPTIONAL property specifies a [descriptor](descriptor.md) of another manifest.
@@ -133,16 +142,94 @@ Unlike the [image index](image-index.md), which contains information about a set
133142

134143
## Example of a SCRATCH config or layer descriptor
135144

136-
Notice that the `mediaType` is subject to the usage or context, while the digest is specifically defined as `ScratchDigestSHA256`
145+
Notice that the `mediaType` is subject to the usage or context, while the digest is specifically defined as `ScratchDigestSHA256`.
146+
When the `ScratchDigestSHA256` is used, the media type SHOULD be set to `application/vnd.oci.scratch.v1+json` to differentiate the descriptor from one pointing to content.
137147

138148
```json,title=SCRATCH%20config&mediatype=application/vnd.oci.descriptor.v1%2Bjson
139149
{
140-
"mediaType": "application/vnd.oci.example+json",
150+
"mediaType": "application/vnd.oci.scratch.v1+json",
141151
"size": 2,
142152
"digest": "sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a"
143153
}
144154
```
145155

156+
## Guidelines for Artifact Usage
157+
158+
Content other than OCI container images MAY be packaged using the image manifest.
159+
When this is done, the `config.mediaType` value MUST be set to a value specific to the artifact type or the [scratch value](#example-of-a-scratch-config-or-layer-descriptor).
160+
If the `config.mediaType` is set to the scratch value, the `artifactType` MUST be defined.
161+
If the artifact does not need layers, a single layer SHOULD be included with a non-zero size.
162+
The suggested content for an unused layer is the [SCRATCH](#example-of-a-scratch-config-or-layer-descriptor) descriptor.
163+
164+
Here is an example manifest for a typical artifact:
165+
166+
```json,title=Artifact%20with%20config&mediatype=application/vnd.oci.image.manifest.v1%2Bjson
167+
{
168+
"schemaVersion": 2,
169+
"mediaType": "application/vnd.oci.image.manifest.v1+json",
170+
"config": {
171+
"mediaType": "application/vnd.example.config.v1+json",
172+
"digest": "sha256:5891b5b522d5df086d0ff0b110fbd9d21bb4fc7163af34d08286a2e846f6be03",
173+
"size": 123
174+
},
175+
"layers": [
176+
{
177+
"mediaType": "application/vnd.example.data.v1.tar+gzip",
178+
"digest": "sha256:e258d248fda94c63753607f7c4494ee0fcbe92f1a76bfdac795c9d84101eb317",
179+
"size": 1234
180+
}
181+
]
182+
}
183+
```
184+
185+
Here is an example manifest for a simple artifact without content in the config, using the scratch descriptor:
186+
187+
```json,title=Artifact%20without%20config&mediatype=application/vnd.oci.image.manifest.v1%2Bjson
188+
{
189+
"schemaVersion": 2,
190+
"mediaType": "application/vnd.oci.image.manifest.v1+json",
191+
"artifactType": "application/vnd.example+type",
192+
"config": {
193+
"mediaType": "application/vnd.oci.scratch.v1+json",
194+
"digest": "sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a",
195+
"size": 2
196+
},
197+
"layers": [
198+
{
199+
"mediaType": "application/vnd.example+type",
200+
"digest": "sha256:e258d248fda94c63753607f7c4494ee0fcbe92f1a76bfdac795c9d84101eb317",
201+
"size": 1234
202+
}
203+
]
204+
}
205+
```
206+
207+
Here is an example manifest for an artifact with only annotations set, and the content of both blobs set to the scratch descriptor:
208+
209+
```json,title=Minimal%20artifact&mediatype=application/vnd.oci.image.manifest.v1%2Bjson
210+
{
211+
"schemaVersion": 2,
212+
"mediaType": "application/vnd.oci.image.manifest.v1+json",
213+
"artifactType": "application/vnd.example+type",
214+
"config": {
215+
"mediaType": "application/vnd.oci.scratch.v1+json",
216+
"digest": "sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a",
217+
"size": 2
218+
},
219+
"layers": [
220+
{
221+
"mediaType": "application/vnd.oci.scratch.v1+json",
222+
"digest": "sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a",
223+
"size": 2
224+
}
225+
],
226+
"annotations": {
227+
"oci.opencontainers.image.created": "2023-01-02T03:04:05Z",
228+
"com.example.data": "payload"
229+
}
230+
}
231+
```
232+
146233
[iana]: https://www.iana.org/assignments/media-types/media-types.xhtml
147234
[rfc6838]: https://tools.ietf.org/html/rfc6838
148235
[rfc6838-s4.2]: https://tools.ietf.org/html/rfc6838#section-4.2

media-types.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ The following media types identify the formats described here and their referenc
1010
- `application/vnd.oci.image.layer.v1.tar`: ["Layer", as a tar archive](layer.md)
1111
- `application/vnd.oci.image.layer.v1.tar+gzip`: ["Layer", as a tar archive](layer.md#gzip-media-types) compressed with [gzip][rfc1952]
1212
- `application/vnd.oci.image.layer.v1.tar+zstd`: ["Layer", as a tar archive](layer.md#zstd-media-types) compressed with [zstd][rfc8478]
13+
- `application/vnd.oci.scratch.v1+json`: [Scratch blob](manifest.md#example-of-a-scratch-config-or-layer-descriptor)
1314
- `application/vnd.oci.artifact.manifest.v1+json`: [Artifact manifest](artifact.md)
1415

1516
The following media types identify a ["Layer" with distribution restrictions](layer.md#non-distributable-layers), but are **deprecated** and not recommended for future use:

schema/image-manifest-schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
"description": "the mediatype of the referenced object",
1616
"$ref": "defs-descriptor.json#/definitions/mediaType"
1717
},
18+
"artifactType": {
19+
"description": "the artifact mediatype of the referenced object",
20+
"$ref": "defs-descriptor.json#/definitions/mediaType"
21+
},
1822
"config": {
1923
"$ref": "content-descriptor.json"
2024
},

schema/manifest_test.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,53 @@ func TestManifest(t *testing.T) {
289289
`,
290290
fail: true,
291291
},
292+
293+
// valid manifest for an artifact with a dedicated config
294+
{
295+
manifest: `
296+
{
297+
"schemaVersion": 2,
298+
"mediaType" : "application/vnd.oci.image.manifest.v1+json",
299+
"config": {
300+
"mediaType": "application/vnd.example.config+json",
301+
"size": 1470,
302+
"digest": "sha256:c86f7763873b6c0aae22d963bab59b4f5debbed6685761b5951584f6efb0633b"
303+
},
304+
"layers": [
305+
{
306+
"mediaType": "application/vnd.example.data+type",
307+
"size": 675598,
308+
"digest": "sha256:9d3dd9504c685a304985025df4ed0283e47ac9ffa9bd0326fddf4d59513f0827"
309+
}
310+
]
311+
}
312+
`,
313+
fail: false,
314+
},
315+
316+
// valid manifest for an artifact using the scratch config and artifactType
317+
{
318+
manifest: `
319+
{
320+
"schemaVersion": 2,
321+
"mediaType" : "application/vnd.oci.image.manifest.v1+json",
322+
"artifactType": "application/vnd.example+type",
323+
"config": {
324+
"mediaType": "application/vnd.oci.scratch.v1+json",
325+
"size": 2,
326+
"digest": "sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a"
327+
},
328+
"layers": [
329+
{
330+
"mediaType": "application/vnd.example+type",
331+
"size": 675598,
332+
"digest": "sha256:9d3dd9504c685a304985025df4ed0283e47ac9ffa9bd0326fddf4d59513f0827"
333+
}
334+
]
335+
}
336+
`,
337+
fail: false,
338+
},
292339
} {
293340
r := strings.NewReader(tt.manifest)
294341
err := schema.ValidatorMediaTypeManifest.Validate(r)

specs-go/v1/manifest.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ type Manifest struct {
2323
// MediaType specifies the type of this document data structure e.g. `application/vnd.oci.image.manifest.v1+json`
2424
MediaType string `json:"mediaType,omitempty"`
2525

26+
// ArtifactType specifies the IANA media type of artifact when the manifest is used for an artifact.
27+
ArtifactType string `json:"artifactType,omitempty"`
28+
2629
// Config references a configuration object for a container, by digest.
2730
// The referenced configuration object is a JSON blob that the runtime uses to set up the container.
2831
Config Descriptor `json:"config"`

specs-go/v1/mediatype.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ const (
7070
// MediaTypeImageConfig specifies the media type for the image configuration.
7171
MediaTypeImageConfig = "application/vnd.oci.image.config.v1+json"
7272

73+
// MediaTypeScratch specifies the media type for an unused blob containing the value `{}`
74+
MediaTypeScratch = "application/vnd.oci.scratch.v1+json"
75+
7376
// MediaTypeArtifactManifest specifies the media type for a content descriptor.
7477
MediaTypeArtifactManifest = "application/vnd.oci.artifact.manifest.v1+json"
7578
)

0 commit comments

Comments
 (0)