Skip to content

Commit f8b2ca8

Browse files
authored
Merge pull request #1068 from sudo-bmitch/pr-rename-scratch
Switch from scratch to empty
2 parents 9615142 + 25fc553 commit f8b2ca8

File tree

6 files changed

+50
-49
lines changed

6 files changed

+50
-49
lines changed

manifest.md

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Unlike the [image index](image-index.md), which contains information about a set
2929
- **`artifactType`** *string*
3030

3131
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).
32+
This MUST be set when `config.mediaType` is set to the [empty value](#guidance-for-an-empty-descriptor).
3333
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].
3434

3535
- **`config`** *[descriptor](descriptor.md)*
@@ -49,16 +49,13 @@ Unlike the [image index](image-index.md), which contains information about a set
4949

5050
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].
5151

52-
To set an effectively NULL or SCRATCH config and maintain portability the following is considered GUIDANCE.
53-
While an empty blob (`size` of 0) may be preferable, practice has shown that not to be ubiquitiously supported.
54-
Instead, the blob payload can be the most minimal content that is still valid JSON object: `{}` (`size` of 2).
55-
The blob digest of `{}` is `sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a`.
56-
See the [example SCRATCH config](#example-of-a-scratch-config-or-layer-descriptor) below, and `ScratchDescriptor` of the reference code.
52+
To set an effectively null or empty config and maintain portability see the [guidance for an empty descriptor](#guidance-for-an-empty-descriptor) below, and `DescriptorEmptyJSON` of the reference code.
5753

5854
- **`layers`** *array of objects*
5955

6056
Each item in the array MUST be a [descriptor](descriptor.md).
6157
For portability, `layers` SHOULD have at least one entry.
58+
See the [guidance for an empty descriptor](#guidance-for-an-empty-descriptor) below, and `DescriptorEmptyJSON` of the reference code.
6259

6360
When the `config.mediaType` is set to `application/vnd.oci.image.config.v1+json`, the following additional restrictions apply:
6461

@@ -67,9 +64,6 @@ Unlike the [image index](image-index.md), which contains information about a set
6764
- The final filesystem layout MUST match the result of [applying](layer.md#applying-changesets) the layers to an empty directory.
6865
- The [ownership, mode, and other attributes](layer.md#file-attributes) of the initial empty directory are unspecified.
6966

70-
For broad portability, if a layer is required to be used, use the SCRATCH layer.
71-
See the [example SCRATCH layer](#example-of-a-scratch-config-or-layer-descriptor) below, and `ScratchDescriptor` of the reference code.
72-
7367
Beyond the [descriptor requirements](descriptor.md#properties), the value has the following additional restrictions:
7468

7569
- **`mediaType`** *string*
@@ -89,7 +83,7 @@ Unlike the [image index](image-index.md), which contains information about a set
8983

9084
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].
9185

92-
See [Guidelines for Artifact Usage](#guidelines-for-artifact-usage) for other uses of the `layers`.
86+
See [Guidelines for Artifact Usage](#guidelines-for-artifact-usage) for other uses of the `layers`.
9387

9488
- **`subject`** *[descriptor](descriptor.md)*
9589

@@ -112,30 +106,30 @@ Unlike the [image index](image-index.md), which contains information about a set
112106
"mediaType": "application/vnd.oci.image.manifest.v1+json",
113107
"config": {
114108
"mediaType": "application/vnd.oci.image.config.v1+json",
115-
"size": 7023,
116-
"digest": "sha256:b5b2b2c507a0944348e0303114d8d93aaaa081732b86451d9bce1f432a537bc7"
109+
"digest": "sha256:b5b2b2c507a0944348e0303114d8d93aaaa081732b86451d9bce1f432a537bc7",
110+
"size": 7023
117111
},
118112
"layers": [
119113
{
120114
"mediaType": "application/vnd.oci.image.layer.v1.tar+gzip",
121-
"size": 32654,
122-
"digest": "sha256:9834876dcfb05cb167a5c24953eba58c4ac89b1adf57f28f2f9d09af107ee8f0"
115+
"digest": "sha256:9834876dcfb05cb167a5c24953eba58c4ac89b1adf57f28f2f9d09af107ee8f0",
116+
"size": 32654
123117
},
124118
{
125119
"mediaType": "application/vnd.oci.image.layer.v1.tar+gzip",
126-
"size": 16724,
127-
"digest": "sha256:3c3a4604a545cdc127456d94e421cd355bca5b528f4a9c1905b15da2eb4a4c6b"
120+
"digest": "sha256:3c3a4604a545cdc127456d94e421cd355bca5b528f4a9c1905b15da2eb4a4c6b",
121+
"size": 16724
128122
},
129123
{
130124
"mediaType": "application/vnd.oci.image.layer.v1.tar+gzip",
131-
"size": 73109,
132-
"digest": "sha256:ec4b8955958665577945c89419d1af06b5f7636b4ac3da7f12184802ad867736"
125+
"digest": "sha256:ec4b8955958665577945c89419d1af06b5f7636b4ac3da7f12184802ad867736",
126+
"size": 73109
133127
}
134128
],
135129
"subject": {
136130
"mediaType": "application/vnd.oci.image.manifest.v1+json",
137-
"size": 7682,
138-
"digest": "sha256:5b0bcabd1ed22e9fb1310cf6c2dec7cdef19f0ad69efa1f392e94a4333501270"
131+
"digest": "sha256:5b0bcabd1ed22e9fb1310cf6c2dec7cdef19f0ad69efa1f392e94a4333501270",
132+
"size": 7682
139133
},
140134
"annotations": {
141135
"com.example.key1": "value1",
@@ -144,28 +138,35 @@ Unlike the [image index](image-index.md), which contains information about a set
144138
}
145139
```
146140

147-
## Example of a SCRATCH config or layer descriptor
141+
## Guidance for an Empty Descriptor
142+
143+
*Implementers note*: The following is considered GUIDANCE for portability.
148144

149-
Notice that the `mediaType` is subject to the usage or context, while the digest is specifically defined as `ScratchDigestSHA256`.
150-
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.
145+
Parts of the spec necessitate including a descriptor to a blob where some implementations of artifacts do not have associated content.
146+
While an empty blob (`size` of 0) may be preferable, practice has shown that not to be ubiquitously supported.
147+
The media type `application/vnd.oci.empty.v1+json` (`MediaTypeEmptyJSON`) has been specified for a descriptor that has no content for the implementation.
148+
The blob payload is the most minimal content that is still a valid JSON object: `{}` (`size` of 2).
149+
The blob digest of `{}` is `sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a`.
150+
The data field is optional, and if included is the base64 encoding of `{}`: `e30=`.
151151

152-
```json,title=SCRATCH%20config&mediatype=application/vnd.oci.descriptor.v1%2Bjson
152+
The resulting descriptor shown here is also defined in reference code as `DescriptorEmptyJSON`:
153+
154+
```json,title=empty%20config&mediatype=application/vnd.oci.descriptor.v1%2Bjson
153155
{
154-
"mediaType": "application/vnd.oci.scratch.v1+json",
156+
"mediaType": "application/vnd.oci.empty.v1+json",
157+
"digest": "sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a",
155158
"size": 2,
156-
"digest": "sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a"
159+
"data": "e30="
157160
}
158161
```
159162

160-
The content of the scratch blob is `{}` (`size` of 2).
161-
162163
## Guidelines for Artifact Usage
163164

164165
Content other than OCI container images MAY be packaged using the image manifest.
165-
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).
166-
If the `config.mediaType` is set to the scratch value, the `artifactType` MUST be defined.
166+
When this is done, the `config.mediaType` value MUST be set to a value specific to the artifact type or the [empty value](#guidance-for-an-empty-descriptor).
167+
If the `config.mediaType` is set to the empty value, the `artifactType` MUST be defined.
167168
If the artifact does not need layers, a single layer SHOULD be included with a non-zero size.
168-
The suggested content for an unused layer is the [SCRATCH](#example-of-a-scratch-config-or-layer-descriptor) descriptor.
169+
The suggested content for an unused `layers` array is the [empty descriptor](#guidance-for-an-empty-descriptor).
169170

170171
Here is an example manifest for a typical artifact:
171172

@@ -188,15 +189,15 @@ Here is an example manifest for a typical artifact:
188189
}
189190
```
190191

191-
Here is an example manifest for a simple artifact without content in the config, using the scratch descriptor:
192+
Here is an example manifest for a simple artifact without content in the config, using the empty descriptor:
192193

193194
```json,title=Artifact%20without%20config&mediatype=application/vnd.oci.image.manifest.v1%2Bjson
194195
{
195196
"schemaVersion": 2,
196197
"mediaType": "application/vnd.oci.image.manifest.v1+json",
197198
"artifactType": "application/vnd.example+type",
198199
"config": {
199-
"mediaType": "application/vnd.oci.scratch.v1+json",
200+
"mediaType": "application/vnd.oci.empty.v1+json",
200201
"digest": "sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a",
201202
"size": 2
202203
},
@@ -210,21 +211,21 @@ Here is an example manifest for a simple artifact without content in the config,
210211
}
211212
```
212213

213-
Here is an example manifest for an artifact with only annotations set, and the content of both blobs set to the scratch descriptor:
214+
Here is an example manifest for an artifact with only annotations set, and the content of both blobs set to the empty descriptor:
214215

215216
```json,title=Minimal%20artifact&mediatype=application/vnd.oci.image.manifest.v1%2Bjson
216217
{
217218
"schemaVersion": 2,
218219
"mediaType": "application/vnd.oci.image.manifest.v1+json",
219220
"artifactType": "application/vnd.example+type",
220221
"config": {
221-
"mediaType": "application/vnd.oci.scratch.v1+json",
222+
"mediaType": "application/vnd.oci.empty.v1+json",
222223
"digest": "sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a",
223224
"size": 2
224225
},
225226
"layers": [
226227
{
227-
"mediaType": "application/vnd.oci.scratch.v1+json",
228+
"mediaType": "application/vnd.oci.empty.v1+json",
228229
"digest": "sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a",
229230
"size": 2
230231
}

media-types.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +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)
13+
- `application/vnd.oci.empty.v1+json`: [Empty for unused descriptors](manifest.md#guidance-for-an-empty-descriptor)
1414

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

schema/manifest_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,15 +313,15 @@ func TestManifest(t *testing.T) {
313313
fail: false,
314314
},
315315

316-
// valid manifest for an artifact using the scratch config and artifactType
316+
// valid manifest for an artifact using the empty config and artifactType
317317
{
318318
manifest: `
319319
{
320320
"schemaVersion": 2,
321321
"mediaType" : "application/vnd.oci.image.manifest.v1+json",
322322
"artifactType": "application/vnd.example+type",
323323
"config": {
324-
"mediaType": "application/vnd.oci.scratch.v1+json",
324+
"mediaType": "application/vnd.oci.empty.v1+json",
325325
"size": 2,
326326
"digest": "sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a"
327327
},

specs-go/v1/descriptor.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,11 @@ type Platform struct {
7070
// example `v7` to specify ARMv7 when architecture is `arm`.
7171
Variant string `json:"variant,omitempty"`
7272
}
73+
74+
// DescriptorEmptyJSON is the descriptor of a blob with content of `{}`.
75+
var DescriptorEmptyJSON = Descriptor{
76+
MediaType: MediaTypeEmptyJSON,
77+
Digest: `sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a`,
78+
Size: 2,
79+
Data: []byte(`{}`),
80+
}

specs-go/v1/manifest.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,3 @@ type Manifest struct {
3939
// Annotations contains arbitrary metadata for the image manifest.
4040
Annotations map[string]string `json:"annotations,omitempty"`
4141
}
42-
43-
// ScratchDescriptor is the descriptor of a blob with content of `{}`.
44-
var ScratchDescriptor = Descriptor{
45-
MediaType: MediaTypeScratch,
46-
Digest: `sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a`,
47-
Size: 2,
48-
Data: []byte(`{}`),
49-
}

specs-go/v1/mediatype.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,6 @@ 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"
73+
// MediaTypeEmptyJSON specifies the media type for an unused blob containing the value `{}`
74+
MediaTypeEmptyJSON = "application/vnd.oci.empty.v1+json"
7575
)

0 commit comments

Comments
 (0)