Skip to content

Commit 0556a6b

Browse files
committed
image-layout: ./refs/ -> index.json
From the 2017-01-25 call we agreed to keep the manifest list as the entry point for accessing objects. The index concept is only a more generic use of the manifest-list. #438 (comment) This change uses the manifest-list as an index that allows implementations to work around needing to walk/traverse the `./refs/` directory. As the `./refs/` directory was REQUIRED to exist, with its removal this `index.json` is REQUIRED to be present. This includes validating the image-layout example. This also makes `validate-examples` automatically update `schema-fs` if there have been changes to the JSON schema. Obsoletes #438 Signed-off-by: Vincent Batts <[email protected]>
1 parent 489e00e commit 0556a6b

12 files changed

+1070
-139
lines changed

Makefile

+8-5
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,14 @@ $(OUTPUT_DIRNAME)/$(DOC_FILENAME).html: $(DOC_FILES) $(FIGURE_FILES)
7575
ls -sh $(shell readlink -f $@)
7676
endif
7777

78-
validate-examples:
78+
validate-examples: schema/fs.go
7979
go test -run TestValidate ./schema
8080

81-
schema-fs:
81+
schema/fs.go: $(wildcard schema/*.json) schema/gen.go
82+
cd schema && printf "%s\n\n%s\n" "$$(cat ../.header)" "$$(go generate)" > fs.go
83+
84+
schema-fs: schema/fs.go
8285
@echo "generating schema fs"
83-
@cd schema && printf "%s\n\n%s\n" "$$(cat ../.header)" "$$(go generate)" > fs.go
8486

8587
check-license:
8688
@echo "checking license headers"
@@ -90,7 +92,7 @@ lint:
9092
@echo "checking lint"
9193
@./.tool/lint
9294

93-
test:
95+
test: schema/fs.go
9496
go test -race -cover $(shell go list ./... | grep -v /vendor/)
9597

9698
img/%.png: img/%.dot
@@ -129,4 +131,5 @@ clean:
129131
clean \
130132
lint \
131133
docs \
132-
test
134+
test \
135+
schema-fs

annotations.md

+1
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ This specification defines the following annotation keys, intended for but not l
2121
* **org.opencontainers.homepage** URL to find more information on the image (string, a URL with scheme HTTP or HTTPS)
2222
* **org.opencontainers.documentation** URL to get documentation on the image (string, a URL with scheme HTTP or HTTPS)
2323
* **org.opencontainers.source** URL to get source code for the binary files in the image (string, a URL with scheme HTTP or HTTPS)
24+
* **org.opencontainers.ref.name** Name of the reference (string)

config.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -229,4 +229,4 @@ Here is an example image configuration JSON document:
229229
```
230230

231231
[rfc3339-s5.6]: https://tools.ietf.org/html/rfc3339#section-5.6
232-
[runtime-platform]: https://github.com/opencontainers/runtime-spec/blob/v1.0.0-rc2/config.md#platform
232+
[runtime-platform]: https://github.com/opencontainers/runtime-spec/blob/v1.0.0-rc3/config.md#platform

image-layout.md

+99-54
Original file line numberDiff line numberDiff line change
@@ -3,47 +3,45 @@
33
The OCI Image Layout is a slash separated layout of OCI content-addressable blobs and [location-addressable](https://en.wikipedia.org/wiki/Content-addressable_storage#Content-addressed_vs._location-addressed) references (refs).
44
This layout MAY be used in a variety of different transport mechanisms: archive formats (e.g. tar, zip), shared filesystem environments (e.g. nfs), or networked file fetching (e.g. http, ftp, rsync).
55

6-
Given an image layout and a ref, a tool can create an [OCI Runtime Specification bundle](https://github.com/opencontainers/runtime-spec/blob/v1.0.0-rc2/bundle.md) by:
6+
Given an image layout and a ref, a tool can create an [OCI Runtime Specification bundle](https://github.com/opencontainers/runtime-spec/blob/v1.0.0-rc3/bundle.md) by:
77

88
* Following the ref to find a [manifest](manifest.md#image-manifest), possibly via a [manifest list](manifest-list.md#manifest-list)
99
* [Applying the filesystem layers](layer.md#applying) in the specified order
10-
* Converting the [image configuration](config.md) into an [OCI Runtime Specification `config.json`](https://github.com/opencontainers/runtime-spec/blob/v1.0.0-rc2/config.md)
10+
* Converting the [image configuration](config.md) into an [OCI Runtime Specification `config.json`](https://github.com/opencontainers/runtime-spec/blob/v1.0.0-rc3/config.md)
1111

1212
# Content
1313

14-
The image layout MUST contain two top level directories:
15-
16-
- `blobs` contains content-addressable blobs.
17-
A blob has no schema and should be considered opaque.
18-
- `refs` contains [descriptors][descriptors].
19-
Commonly pointing to an [image manifest](manifest.md#image-manifest) or an [image manifest list](manifest-list.md#oci-image-manifest-list-specification).
20-
21-
Both `blobs` and `refs` MAY be empty.
22-
23-
The image layout MUST also contain an `oci-layout` file:
24-
25-
- It MUST be a JSON object
26-
- It MUST contain an `imageLayoutVersion` field
27-
- The `imageLayoutVersion` value will align with the OCI Image Specification version at the time changes to the layout are made, and will pin a given version until changes to the layout are required
28-
- It MAY include additional fields
14+
The image layout is as follows:
15+
16+
- `blobs` directory
17+
- Contains content-addressable blobs
18+
- A blob has no schema and should be considered opaque
19+
- Directory MUST exist and MAY be empty
20+
- See [blobs](#blobs) section
21+
- `oci-layout` file
22+
- It MUST exist
23+
- It MUST be a JSON object
24+
- It MUST contain an `imageLayoutVersion` field
25+
- See [oci-layout file](#oci-layout-file) section
26+
- It MAY include additional fields
27+
- `index.json` file
28+
- It MUST exist
29+
- It MUST be a JSON object
30+
- It MUST have the base properties of [manifest-list](manifest-list.md).
31+
- See [index.json](#indexjson-file) section
2932

3033
## Example Layout
3134

3235
This is an example image layout:
3336

3437
```
3538
$ cd example.com/app/
36-
$ find .
37-
.
38-
./blobs
39-
./blobs/sha256/e692418e4cbaf90ca69d05a66403747baa33ee08806650b51fab815ad7fc331f
40-
./blobs/sha256/afff3924849e458c5ef237db5f89539274d5e609db5db935ed3959c90f1f2d51
41-
./blobs/sha256/9b97579de92b1c195b85bb42a11011378ee549b02d7fe9c17bf2a6b35d5cb079
42-
./blobs/sha256/5b0bcabd1ed22e9fb1310cf6c2dec7cdef19f0ad69efa1f392e94a4333501270
39+
$ find . -type f
40+
./index.json
4341
./oci-layout
44-
./refs
45-
./refs/v1.0
46-
./refs/stable-release
42+
./blobs/sha256/3588d02542238316759cbf24502f4344ffcc8a60c803870022f335d1390c13b4
43+
./blobs/sha256/4b0bc1c4050b03c95ef2a8e36e25feac42fd31283e8c30b3ee5df6b043155d3c
44+
./blobs/sha256/7968321274dc6b6171697c33df7815310468e694ac5be0ec03ff053bb135e768
4745
```
4846

4947
Blobs are named by their contents:
@@ -53,33 +51,6 @@ $ shasum -a 256 ./blobs/sha256/afff3924849e458c5ef237db5f89539274d5e609db5db935e
5351
afff3924849e458c5ef237db5f89539274d5e609db5db935ed3959c90f1f2d51 ./blobs/sha256/afff3924849e458c5ef237db5f89539274d5e609db5db935ed3959c90f1f2d51
5452
```
5553

56-
## Refs
57-
58-
Object names in the `refs` subdirectories MUST NOT include characters outside of the set of "A" to "Z", "a" to "z", "0" to "9", the hyphen `-`, the dot `.`, and the underscore `_`.
59-
60-
No semantic restriction is given for object names in the `refs` subdirectory.
61-
Each object in the `refs` subdirectory MUST be of type `application/vnd.oci.descriptor.v1+json`.
62-
In general the `mediaType` of this [descriptor][descriptors] object will be either `application/vnd.oci.image.manifest.list.v1+json` or `application/vnd.oci.image.manifest.v1+json` although future versions of the spec MAY use a different mediatype.
63-
64-
**Implementor's Note:**
65-
A common use case of refs is representing "tags" for a container image.
66-
For example, an image may have a tag for different versions or builds of the software.
67-
In the wild you often see "tags" like "v1.0.0-vendor.0", "2.0.0-debug", etc.
68-
Those tags will often be represented in an image-layout repository with matching refs names like "v1.0.0-vendor.0", "2.0.0-debug", etc.
69-
70-
### Example Ref
71-
72-
This is an example `v1.0` ref with a manifest-list descriptor:
73-
74-
```
75-
$ cat ./refs/v1.0 | jq
76-
{
77-
"size": 4096,
78-
"digest": "sha256:e692418e4cbaf90ca69d05a66403747baa33ee08806650b51fab815ad7fc331f",
79-
"mediaType": "application/vnd.oci.image.manifest.list.v1+json"
80-
}
81-
```
82-
8354
## Blobs
8455

8556
Object names in the `blobs` subdirectories are composed of a directory for each hash algorithm, the children of which will contain the actual content.
@@ -156,4 +127,78 @@ $ cat ./blobs/sha256/e692418e4cbaf90ca69d05a66403747baa33ee08806650b51fab815ad7f
156127
[tar stream]
157128
```
158129

130+
## oci-layout file
131+
132+
This JSON object serves as a marker for the base of an Open Container Image Layout and to provide the version of the image-layout in use.
133+
The `imageLayoutVersion` value will align with the OCI Image Specification version at the time changes to the layout are made, and will pin a given version until changes to the image layout are required.
134+
135+
### oci-layout Example
136+
137+
```json
138+
{
139+
"imageLayoutVersion": "1.0.0"
140+
}
141+
```
142+
143+
## index.json file
144+
145+
This REQUIRED file is the entry point for references and descriptors of the image-layout.
146+
The [manifest-list](manifest-list.md) is a multi-descriptor entry point.
147+
148+
This index provides an established path (`/index.json`) to have an entry point for an image-layout and to discover auxiliary descriptors.
149+
150+
No semantic restriction is given for the "org.opencontainers.ref.name" annotation of descriptors.
151+
In general the `mediaType` of each [descriptor][descriptors] object in the `manifests` field will be either `application/vnd.oci.image.manifest.list.v1+json` or `application/vnd.oci.image.manifest.v1+json`
152+
Future versions of the spec MAY use a different mediatype (i.e. a new versioned format).
153+
An encountered `mediaType` that is unknown SHOULD be safely ignored.
154+
155+
156+
**Implementor's Note:**
157+
A common use case of descriptors with a "org.opencontainers.ref.name" annotation is representing a "tag" for a container image.
158+
For example, an image may have a tag for different versions or builds of the software.
159+
In the wild you often see "tags" like "v1.0.0-vendor.0", "2.0.0-debug", etc.
160+
Those tags will often be represented in an image-layout repository with matching "org.opencontainers.ref.name" annotations like "v1.0.0-vendor.0", "2.0.0-debug", etc.
161+
162+
163+
### Index Example
164+
165+
```json,title=Manifest%20List&mediatype=application/vnd.oci.image.manifest.list.v1%2Bjson
166+
{
167+
"schemaVersion": 2,
168+
"manifests": [
169+
{
170+
"mediaType": "application/vnd.oci.image.manifest.v1+json",
171+
"size": 7143,
172+
"digest": "sha256:0228f90e926ba6b96e4f39cf294b2586d38fbb5a1e385c05cd1ee40ea54fe7fd",
173+
"annotations": {
174+
"org.opencontainers.ref.name": "stable-release"
175+
}
176+
},
177+
{
178+
"mediaType": "application/vnd.oci.image.manifest.v1+json",
179+
"size": 7143,
180+
"digest": "sha256:e692418e4cbaf90ca69d05a66403747baa33ee08806650b51fab815ad7fc331f",
181+
"annotations": {
182+
"org.opencontainers.ref.name": "v1.0"
183+
}
184+
},
185+
{
186+
"mediaType": "application/xml",
187+
"size": 7143,
188+
"digest": "sha256:b3d63d132d21c3ff4c35a061adf23cf43da8ae054247e32faa95494d904a007e",
189+
"annotations": {
190+
"org.freedesktop.specifications.metainfo.version": "1.0",
191+
"org.freedesktop.specifications.metainfo.type": "AppStream"
192+
}
193+
}
194+
],
195+
"annotations": {
196+
"com.example.index.revision": "r124356"
197+
}
198+
}
199+
```
200+
201+
This illustrates an index that provides two named manifest references and an auxilary mediatype for this image layout.
202+
203+
159204
[descriptors]: ./descriptor.md

manifest-list.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ For the media type(s) that this document is compatible with, see the [matrix][ma
1111
- **`schemaVersion`** *int*
1212

1313
This REQUIRED property specifies the image manifest schema version.
14-
For this version of the specification, this MUST be `2` to ensure backward compatibility with older versions of Docker. The value of this field will not change. This field MAY be removed in a future version of the specification.
14+
For this version of the specification, this MUST be `2` to ensure backward compatibility with older versions of Docker.
15+
The value of this field will not change.
16+
This field MAY be removed in a future version of the specification.
1517

1618
- **`mediaType`** *string*
1719

@@ -103,5 +105,5 @@ For the media type(s) that this document is compatible with, see the [matrix][ma
103105
}
104106
```
105107

106-
[runtime-platform2]: https://github.com/opencontainers/runtime-spec/blob/v1.0.0-rc2/config.md#platform
108+
[runtime-platform2]: https://github.com/opencontainers/runtime-spec/blob/v1.0.0-rc3/config.md#platform
107109
[matrix]: media-types.md#compatibility-matrix

schema/content-descriptor.json

+4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
"type": "string",
2424
"format": "uri"
2525
}
26+
},
27+
"annotations": {
28+
"id": "https://opencontainers.org/schema/image/descriptor/annotations",
29+
"$ref": "defs-image.json#/definitions/annotations"
2630
}
2731
},
2832
"required": [

schema/defs-image.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
"required": [
1818
"mediaType",
1919
"size",
20-
"digest",
21-
"platform"
20+
"digest"
2221
],
2322
"properties": {
2423
"mediaType": {
@@ -78,6 +77,10 @@
7877
}
7978
}
8079
}
80+
},
81+
"annotations": {
82+
"id": "https://opencontainers.org/schema/image/descriptor/annotations",
83+
"$ref": "#/definitions/annotations"
8184
}
8285
}
8386
},

0 commit comments

Comments
 (0)