Skip to content

Commit 729a03e

Browse files
committed
manifest, specs-go/: provide guidance on SCRATCH config descriptor
Ref: #1025 Through the conversations between artifact manifest and standardizing the misuse of the image-manifest one of the topics was around when there is _not_ a `config` needed for the `layers`/blobs. Since the `config` is a REQUIRED field, it meant setting this to some valid value. This guidance intends to set a norm for a blob that need only be pushed to a registry a single time, and then save on round trips for all future SCRATCH configs, while also being most widely portability. to facilitate use by tools that import this reference code to identify this specific blob when working with an empty/scratch config blob and layer blob. This will utilize the same blob for both Signed-off-by: Vincent Batts <[email protected]>
1 parent 819aa94 commit 729a03e

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

manifest.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ Unlike the [image index](image-index.md), which contains information about a set
4242

4343
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].
4444

45+
To set an effectively NULL or SCRATCH config and maintain portability the following is considered GUIDANCE.
46+
While an empty blob (`size` of 0) may be preferable, practice has shown that not to be ubiquitiously supported.
47+
Instead, the blob payload can be the most minimal content that is still valid JSON object: `{}` (`size` of 2).
48+
The blob digest of `{}` is `sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a`.
49+
See the [example SCRATCH config](#example-of-a-scratch-config-or-layer-descriptor) below, and the `ScratchDescriptor()` of the reference code.
50+
4551
- **`layers`** *array of objects*
4652

4753
Each item in the array MUST be a [descriptor](descriptor.md).
@@ -50,6 +56,9 @@ Unlike the [image index](image-index.md), which contains information about a set
5056
The final filesystem layout MUST match the result of [applying](layer.md#applying-changesets) the layers to an empty directory.
5157
The [ownership, mode, and other attributes](layer.md#file-attributes) of the initial empty directory are unspecified.
5258

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

5564
- **`mediaType`** *string*
@@ -122,6 +131,18 @@ Unlike the [image index](image-index.md), which contains information about a set
122131
}
123132
```
124133

134+
## Example of a SCRATCH config or layer descriptor
135+
136+
Notice that the `mediaType` is subject to the usage or context, while the digest is specifically defined as `ScratchDigestSHA256`
137+
138+
```json,title=SCRATCH%20config&mediatype=application/vnd.oci.descriptor.v1%2Bjson
139+
{
140+
"mediaType": "application/vnd.oci.example+json",
141+
"size": 2,
142+
"digest": "sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a"
143+
}
144+
```
145+
125146
[iana]: https://www.iana.org/assignments/media-types/media-types.xhtml
126147
[rfc6838]: https://tools.ietf.org/html/rfc6838
127148
[rfc6838-s4.2]: https://tools.ietf.org/html/rfc6838#section-4.2

specs-go/v1/manifest.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,7 @@ type Manifest struct {
3636
// Annotations contains arbitrary metadata for the image manifest.
3737
Annotations map[string]string `json:"annotations,omitempty"`
3838
}
39+
40+
// ScratchDigestSHA256 is the digest of a blob with content of `{}` (size of 2)
41+
const ScratchDigestSHA256 = `sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a`
42+
const ScratchDigestData = `{}`

0 commit comments

Comments
 (0)