Skip to content

Commit ff02571

Browse files
authored
Merge pull request #934 from oci-playground/pr
Working Group Proposal for Reference Types
2 parents d265d74 + b04b320 commit ff02571

11 files changed

+214
-12
lines changed

annotations.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@ This property contains arbitrary metadata.
1616

1717
## Pre-Defined Annotation Keys
1818

19-
This specification defines the following annotation keys, intended for but not limited to [image index](image-index.md) and image [manifest](manifest.md) authors:
20-
* **org.opencontainers.image.created** date and time on which the image was built (string, date-time as defined by [RFC 3339](https://tools.ietf.org/html/rfc3339#section-5.6)).
19+
This specification defines the following annotation keys, intended for but not limited to [image index](image-index.md), image [manifest](manifest.md), [artifact](artifact.md), and [descriptor](descriptor.md) authors.
20+
21+
* **org.opencontainers.artifact.created** date and time on which the artifact was built, conforming to [RFC 3339][rfc3339].
22+
* **org.opencontainers.artifact.description**: human readable description for the artifact (string)
23+
* **org.opencontainers.image.created** date and time on which the image was built, conforming to [RFC 3339][rfc3339].
2124
* **org.opencontainers.image.authors** contact details of the people or organization responsible for the image (freeform string)
2225
* **org.opencontainers.image.url** URL to find more information on the image (string)
2326
* **org.opencontainers.image.documentation** URL to get documentation on the image (string)
@@ -49,6 +52,7 @@ This specification defines the following annotation keys, intended for but not l
4952
* This SHOULD be the immediate image sharing zero-indexed layers with the image, such as from a Dockerfile `FROM` statement.
5053
* This SHOULD NOT reference any other images used to generate the contents of the image (e.g., multi-stage Dockerfile builds).
5154
* If the `image.base.name` annotation is specified, the `image.base.digest` annotation SHOULD be the digest of the manifest referenced by the `image.ref.name` annotation.
55+
* **org.opencontainers.referrers.filtersApplied** Comma separated list of filters applied by the registry in the [referrers listing](https://github.com/opencontainers/distribution-spec/blob/main/spec.md#listing-referrers) (string)
5256
5357
## Back-compatibility with Label Schema
5458
@@ -74,3 +78,5 @@ While users are encouraged to use the **org.opencontainers.image** keys, tools M
7478
| | `docker.*`, `rkt.*` | No equivalent in the OCI Image Spec |
7579
7680
[spdx-license-expression]: https://spdx.org/spdx-specification-21-web-version#h.jxpfx0ykyb60
81+
82+
[rfc3339]: https://tools.ietf.org/html/rfc3339#section-5.6

artifact.md

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# OCI Artifact Manifest Specification
2+
3+
The goal of the Artifact Manifest Specification is to define content addressable artifacts in order to store them along side container images in a registry.
4+
Like [OCI Images](manifest.md), OCI Artifacts may be referenced by the hash of their manifest.
5+
Unlike OCI Images, OCI Artifacts are not meant to be used by any container runtime.
6+
7+
Examples of artifacts that may be stored along with container images are Software Bill of Materials (SBOM), Digital Signatures, Provenance data, Supply Chain Attestations, scan results, and Helm charts.
8+
9+
This section defines the `application/vnd.oci.artifact.manifest.v1+json` [media type](media-types.md).
10+
For the media type(s) that this is compatible with see the [matrix](media-types.md#compatibility-matrix).
11+
12+
# Artifact Manifest
13+
14+
## *Artifact Manifest* Property Descriptions
15+
16+
- **`mediaType`** *string*
17+
18+
This property MUST be used and contain the media type `application/vnd.oci.artifact.manifest.v1+json`.
19+
20+
- **`artifactType`** *string*
21+
22+
This property SHOULD be used and contain the mediaType of the referenced artifact.
23+
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].
24+
25+
- **`blobs`** *array of objects*
26+
27+
This OPTIONAL property is an array of objects and each item in the array MUST be a [descriptor](descriptor.md).
28+
Each descriptor represents an artifact of any IANA mediaType.
29+
The list MAY be ordered for certain artifact types like scan results.
30+
31+
- **`refers`** *[descriptor](descriptor.md)*
32+
33+
This OPTIONAL property specifies a [descriptor](descriptor.md) of another manifest.
34+
This value, used by the [`referrers` API](https://github.com/opencontainers/distribution-spec/blob/main/spec.md#listing-referrers), indicates a relationship to the specified manifest.
35+
36+
- **`annotations`** *string-string map*
37+
38+
This OPTIONAL property contains additional metadata for the artifact manifest.
39+
This OPTIONAL property MUST use the [annotation rules](annotations.md#rules).
40+
41+
See [Pre-Defined Annotation Keys](annotations.md#pre-defined-annotation-keys).
42+
43+
Annotations MAY be used to filter the response from the [`referrers` API](https://github.com/opencontainers/distribution-spec/blob/main/spec.md#listing-referrers).
44+
45+
## Examples
46+
47+
*Example showing an artifact manifest for an example SBOM referencing an image:*
48+
49+
```jsonc,title=Manifest&mediatype=application/vnd.oci.artifact.manifest.v1%2Bjson
50+
{
51+
"mediaType": "application/vnd.oci.artifact.manifest.v1+json",
52+
"artifactType": "application/vnd.example.sbom.v1"
53+
"blobs": [
54+
{
55+
"mediaType": "application/gzip",
56+
"size": 123,
57+
"digest": "sha256:87923725d74f4bfb94c9e86d64170f7521aad8221a5de834851470ca142da630"
58+
}
59+
],
60+
"refers": {
61+
"mediaType": "application/vnd.oci.image.manifest.v1+json",
62+
"size": 1234,
63+
"digest": "sha256:cc06a2839488b8bd2a2b99dcdc03d5cfd818eed72ad08ef3cc197aac64c0d0a0"
64+
},
65+
"annotations": {
66+
"org.opencontainers.artifact.created": "2022-01-01T14:42:55Z",
67+
"org.example.sbom.format": "json"
68+
}
69+
}
70+
```
71+
72+
[iana]: https://www.iana.org/assignments/media-types/media-types.xhtml
73+
[rfc6838]: https://tools.ietf.org/html/rfc6838
74+
[rfc6838-s4.2]: https://tools.ietf.org/html/rfc6838#section-4.2

descriptor.md

+31-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# OCI Content Descriptors
22

3-
* An OCI image consists of several different components, arranged in a [Merkle Directed Acyclic Graph (DAG)](https://en.wikipedia.org/wiki/Merkle_tree).
4-
* References between components in the graph are expressed through _Content Descriptors_.
5-
* A Content Descriptor (or simply _Descriptor_) describes the disposition of the targeted content.
6-
* A Content Descriptor includes the type of the content, a content identifier (_digest_), and the byte-size of the raw content.
7-
* Descriptors SHOULD be embedded in other formats to securely reference external content.
8-
* Other formats SHOULD use descriptors to securely reference external content.
3+
- An OCI image consists of several different components, arranged in a [Merkle Directed Acyclic Graph (DAG)](https://en.wikipedia.org/wiki/Merkle_tree).
4+
- References between components in the graph are expressed through _Content Descriptors_.
5+
- A Content Descriptor (or simply _Descriptor_) describes the disposition of the targeted content.
6+
- A Content Descriptor includes the type of the content, a content identifier (_digest_), and the byte-size of the raw content.
7+
Optionally, it includes the type of artifact it is describing.
8+
- Descriptors SHOULD be embedded in other formats to securely reference external content.
9+
- Other formats SHOULD use descriptors to securely reference external content.
910

1011
This section defines the `application/vnd.oci.descriptor.v1+json` [media type](media-types.md).
1112

@@ -51,8 +52,16 @@ The following fields contain the primary properties that constitute a Descriptor
5152
The decoded data MUST be identical to the referenced content and SHOULD be verified against the [`digest`](#digests) and `size` fields by content consumers.
5253
See [Embedded Content](#embedded-content) for when this is appropriate.
5354

55+
- **`artifactType`** *string*
56+
57+
This OPTIONAL property contains the type of an artifact when the descriptor points to an artifact.
58+
This is the value of `artifactType` when the descriptor references an [artifact manifest](artifact.md).
59+
This is the value of the config descriptor `mediaType` when the descriptor references an [image manifest](manifest.md).
60+
5461
Descriptors pointing to [`application/vnd.oci.image.manifest.v1+json`](manifest.md) SHOULD include the extended field `platform`, see [Image Index Property Descriptions](image-index.md#image-index-property-descriptions) for details.
5562

63+
Descriptors pointing to [`application/vnd.oci.artifact.manifest.v1+json`](artifact.md) SHOULD include the extended field `artifactType`.
64+
5665
### Reserved
5766

5867
Extended _Descriptor_ field additions proposed in other OCI specifications SHOULD first be considered for addition into this specification.
@@ -68,7 +77,7 @@ The _algorithm_ specifies the cryptographic hash function and encoding used for
6877

6978
A digest string MUST match the following [grammar](considerations.md#ebnf):
7079

71-
```
80+
```ebnf
7281
digest ::= algorithm ":" encoded
7382
algorithm ::= algorithm-component (algorithm-separator algorithm-component)*
7483
algorithm-component ::= [a-z0-9]+
@@ -104,12 +113,14 @@ Implementations MAY employ [canonicalization](considerations.md#canonicalization
104113
### Digest calculations
105114

106115
A _digest_ is calculated by the following pseudo-code, where `H` is the selected hash algorithm, identified by string `<alg>`:
107-
```
116+
117+
```text
108118
let ID(C) = Descriptor.digest
109119
let C = <bytes>
110120
let D = '<alg>:' + Encode(H(C))
111121
let verified = ID(C) == D
112122
```
123+
113124
Above, we define the content identifier as `ID(C)`, extracted from the `Descriptor.digest` field.
114125
Content `C` is a string of bytes.
115126
Function `H` returns the hash of `C` in bytes and is passed to function `Encode` and prefixed with the algorithm to obtain the digest.
@@ -190,6 +201,17 @@ In the following example, the descriptor indicates that the referenced manifest
190201
}
191202
```
192203

204+
In the following example, the descriptor indicates the type of artifact it is referencing:
205+
206+
```json,title=Content%20Descriptor&mediatype=application/vnd.oci.descriptor.v1%2Bjson
207+
{
208+
"mediaType": "application/vnd.oci.artifact.manifest.v1+json",
209+
"size": 123,
210+
"digest": "sha256:87923725d74f4bfb94c9e86d64170f7521aad8221a5de834851470ca142da630",
211+
"artifactType": "application/vnd.example.sbom.v1"
212+
}
213+
```
214+
193215
[rfc3986]: https://tools.ietf.org/html/rfc3986
194216
[rfc4634-s4.1]: https://tools.ietf.org/html/rfc4634#section-4.1
195217
[rfc4634-s4.2]: https://tools.ietf.org/html/rfc4634#section-4.2
@@ -198,3 +220,4 @@ In the following example, the descriptor indicates that the referenced manifest
198220
[rfc6838-s4.2]: https://tools.ietf.org/html/rfc6838#section-4.2
199221
[rfc7230-s2.7]: https://tools.ietf.org/html/rfc7230#section-2.7
200222
[sha256-vs-sha512]: https://groups.google.com/a/opencontainers.org/forum/#!topic/dev/hsMw7cAwrZE
223+
[iana]: https://www.iana.org/assignments/media-types/media-types.xhtml

image-index.md

+36
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ For the media type(s) that this document is compatible with, see the [matrix][ma
3535
Implementations MUST support at least the following media types:
3636

3737
- [`application/vnd.oci.image.manifest.v1+json`](manifest.md)
38+
- [`application/vnd.oci.artifact.manifest.v1+json`](artifact.md)
3839

3940
Also, implementations SHOULD support the following media types:
4041

@@ -137,5 +138,40 @@ When the variant of the CPU is not listed in the table, values are implementatio
137138
}
138139
```
139140

141+
## Example Image Index with multiple media types
142+
143+
*Example showing an image index pointing to manifests with multiple media types:*
144+
```json,title=Image%20Index&mediatype=application/vnd.oci.image.index.v1%2Bjson
145+
{
146+
"schemaVersion": 2,
147+
"mediaType": "application/vnd.oci.image.index.v1+json",
148+
"manifests": [
149+
{
150+
"mediaType": "application/vnd.oci.image.manifest.v1+json",
151+
"size": 7143,
152+
"digest": "sha256:e692418e4cbaf90ca69d05a66403747baa33ee08806650b51fab815ad7fc331f",
153+
"platform": {
154+
"architecture": "ppc64le",
155+
"os": "linux"
156+
}
157+
},
158+
{
159+
"mediaType": "application/vnd.oci.artifact.manifest.v1+json",
160+
"size": 7682,
161+
"digest": "sha256:601570aaff1b68a61eb9c85b8beca1644e698003e0cdb5bce960f193d265a8b7",
162+
"artifactType": "application/example",
163+
"annotations": {
164+
"com.example.artifactKey1": "value1",
165+
"com.example.artifactKey2": "value2"
166+
}
167+
}
168+
],
169+
"annotations": {
170+
"com.example.key1": "value1",
171+
"com.example.key2": "value2"
172+
}
173+
}
174+
```
175+
140176
[go-environment2]: https://golang.org/doc/install/source#environment
141177
[matrix]: media-types.md#compatibility-matrix

manifest.md

+10
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ Unlike the [image index](image-index.md), which contains information about a set
6565

6666
Entries in this field will frequently use the `+gzip` types.
6767

68+
- **`refers`** *[descriptor](descriptor.md)*
69+
70+
This OPTIONAL property specifies a [descriptor](descriptor.md) of another manifest.
71+
This value, used by the [`referrers` API](https://github.com/opencontainers/distribution-spec/blob/main/spec.md#listing-referrers), indicates a relationship to the specified manifest.
72+
6873
- **`annotations`** *string-string map*
6974

7075
This OPTIONAL property contains arbitrary metadata for the image manifest.
@@ -101,6 +106,11 @@ Unlike the [image index](image-index.md), which contains information about a set
101106
"digest": "sha256:ec4b8955958665577945c89419d1af06b5f7636b4ac3da7f12184802ad867736"
102107
}
103108
],
109+
"refers": {
110+
"mediaType": "application/vnd.oci.image.manifest.v1+json",
111+
"size": 7682,
112+
"digest": "sha256:5b0bcabd1ed22e9fb1310cf6c2dec7cdef19f0ad69efa1f392e94a4333501270"
113+
},
104114
"annotations": {
105115
"com.example.key1": "value1",
106116
"com.example.key2": "value2"

media-types.md

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ The following media types identify the formats described here and their referenc
1313
- `application/vnd.oci.image.layer.nondistributable.v1.tar`: ["Layer", as a tar archive with distribution restrictions](layer.md#non-distributable-layers)
1414
- `application/vnd.oci.image.layer.nondistributable.v1.tar+gzip`: ["Layer", as a tar archive with distribution restrictions](layer.md#gzip-media-types) compressed with [gzip][rfc1952]
1515
- `application/vnd.oci.image.layer.nondistributable.v1.tar+zstd`: ["Layer", as a tar archive with distribution restrictions](layer.md#zstd-media-types) compressed with [zstd][rfc8478]
16+
- `application/vnd.oci.artifact.manifest.v1+json`: [Artifact manifest](artifact.md)
1617

1718
## Media Type Conflicts
1819

specs-go/v1/annotations.go

+9
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,13 @@ const (
5959

6060
// AnnotationBaseImageName is the annotation key for the image reference of the image's base image.
6161
AnnotationBaseImageName = "org.opencontainers.image.base.name"
62+
63+
// AnnotationArtifactCreated is the annotation key for the date and time on which the artifact was built, conforming to RFC 3339.
64+
AnnotationArtifactCreated = "org.opencontainers.artifact.created"
65+
66+
// AnnotationArtifactDescription is the annotation key for the human readable description for the artifact.
67+
AnnotationArtifactDescription = "org.opencontainers.artifact.description"
68+
69+
// AnnotationReferrersFiltersApplied is the annotation key for the comma separated list of filters applied by the registry in the referrers listing.
70+
AnnotationReferrersFiltersApplied = "org.opencontainers.referrers.filtersApplied"
6271
)

specs-go/v1/artifact.go

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright 2022 The Linux Foundation
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package v1
16+
17+
// Artifact describes an artifact manifest.
18+
// This structure provides `application/vnd.oci.artifact.manifest.v1+json` mediatype when marshalled to JSON.
19+
type Artifact struct {
20+
// MediaType is the media type of the object this schema refers to.
21+
MediaType string `json:"mediaType"`
22+
23+
// ArtifactType is the IANA media type of the artifact this schema refers to.
24+
ArtifactType string `json:"artifactType"`
25+
26+
// Blobs is a collection of blobs referenced by this manifest.
27+
Blobs []Descriptor `json:"blobs,omitempty"`
28+
29+
// Refers is an optional link to any existing manifest within the repository.
30+
Refers *Descriptor `json:"refers,omitempty"`
31+
32+
// Annotations contains arbitrary metadata for the artifact manifest.
33+
Annotations map[string]string `json:"annotations,omitempty"`
34+
}

specs-go/v1/descriptor.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2016 The Linux Foundation
1+
// Copyright 2016-2022 The Linux Foundation
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -44,6 +44,9 @@ type Descriptor struct {
4444
//
4545
// This should only be used when referring to a manifest.
4646
Platform *Platform `json:"platform,omitempty"`
47+
48+
// ArtifactType is the IANA media type of this artifact.
49+
ArtifactType string `json:"artifactType,omitempty"`
4750
}
4851

4952
// Platform describes the platform which the image in the manifest runs on.

specs-go/v1/manifest.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2016 The Linux Foundation
1+
// Copyright 2016-2022 The Linux Foundation
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -30,6 +30,9 @@ type Manifest struct {
3030
// Layers is an indexed list of layers referenced by the manifest.
3131
Layers []Descriptor `json:"layers"`
3232

33+
// Refers is an optional link to any existing manifest within the repository.
34+
Refers *Descriptor `json:"refers,omitempty"`
35+
3336
// Annotations contains arbitrary metadata for the image manifest.
3437
Annotations map[string]string `json:"annotations,omitempty"`
3538
}

specs-go/v1/mediatype.go

+3
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,7 @@ const (
5454

5555
// MediaTypeImageConfig specifies the media type for the image configuration.
5656
MediaTypeImageConfig = "application/vnd.oci.image.config.v1+json"
57+
58+
// MediaTypeArtifactManifest specifies the media type for a content descriptor.
59+
MediaTypeArtifactManifest = "application/vnd.oci.artifact.manifest.v1+json"
5760
)

0 commit comments

Comments
 (0)