Skip to content

Commit 28e7ed9

Browse files
committed
image-layout: OPTIONAL 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/` or `./blobs/` directories. 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 9ad15cf commit 28e7ed9

File tree

12 files changed

+307
-98
lines changed

12 files changed

+307
-98
lines changed

Makefile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,15 @@ $(OUTPUT_DIRNAME)/$(DOC_FILENAME).html: $(DOC_FILES) $(FIGURE_FILES)
7676
ls -sh $(shell readlink -f $@)
7777
endif
7878

79-
validate-examples:
79+
validate-examples: schema/fs.go
8080
go test -run TestValidate ./schema
8181

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

8689
check-license:
8790
@echo "checking license headers"

annotations.md

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 59 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,24 @@
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

1414
The image layout MUST contain two top level directories:
1515

1616
- `blobs` contains content-addressable blobs.
17-
A blob has no schema and should be considered opaque.
17+
- A blob has no schema and should be considered opaque.
18+
- Directory MAY be empty.
19+
- See [blobs](#blobs) section
1820
- `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.
21+
- Commonly pointing to an [image manifest](manifest.md#image-manifest) or an [image manifest list](manifest-list.md#oci-image-manifest-list-specification).
22+
- Directory MAY be empty.
23+
- See [refs](#refs) section
2224

2325
The image layout MUST also contain an `oci-layout` file:
2426

@@ -27,23 +29,26 @@ The image layout MUST also contain an `oci-layout` file:
2729
- 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
2830
- It MAY include additional fields
2931

32+
The image layout MAY also contain an `index.json` file:
33+
34+
- It MUST be a JSON object
35+
- It MUST have the base properties of [manifest-list](manifest-list.md).
36+
- See [index.json](#index.json) section
37+
3038
## Example Layout
3139

3240
This is an example image layout:
3341

3442
```
3543
$ 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
43-
./oci-layout
44-
./refs
44+
$ find . -type f
45+
./index.json
4546
./refs/v1.0
4647
./refs/stable-release
48+
./oci-layout
49+
./blobs/sha256/3588d02542238316759cbf24502f4344ffcc8a60c803870022f335d1390c13b4
50+
./blobs/sha256/4b0bc1c4050b03c95ef2a8e36e25feac42fd31283e8c30b3ee5df6b043155d3c
51+
./blobs/sha256/7968321274dc6b6171697c33df7815310468e694ac5be0ec03ff053bb135e768
4752
```
4853

4954
Blobs are named by their contents:
@@ -156,4 +161,43 @@ $ cat ./blobs/sha256/e692418e4cbaf90ca69d05a66403747baa33ee08806650b51fab815ad7f
156161
[tar stream]
157162
```
158163

164+
## index.json
165+
166+
This OPTIONAL file is for use indexing references and elements of the image-layout, where walking the `refs` and `blobs` is sub-optimal.
167+
It is intended to be generated from the content in an image-layout after any changes.
168+
169+
From the base properties of the [manifest-list](manifest-list.md), this object will us
170+
171+
### Index Example
172+
173+
```json,title=Manifest%20List&mediatype=application/vnd.oci.image.manifest.list.v1%2Bjson
174+
{
175+
"schemaVersion": 2,
176+
"manifests": [
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+
"elements": [
187+
{
188+
"mediaType": "application/xml",
189+
"size": 7143,
190+
"digest": "sha256:b3d63d132d21c3ff4c35a061adf23cf43da8ae054247e32faa95494d904a007e",
191+
"annotations": {
192+
"org.freedesktop.specifications.metainfo.version": "1.0",
193+
"org.freedesktop.specifications.metainfo.type": "AppStream"
194+
}
195+
}
196+
],
197+
"annotations": {
198+
"com.example.index.revision": "r124356"
199+
}
200+
}
201+
```
202+
159203
[descriptors]: ./descriptor.md

manifest-list.md

Lines changed: 4 additions & 2 deletions
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

@@ -114,5 +116,5 @@ For the media type(s) that this document is compatible with, see the [matrix][ma
114116
}
115117
```
116118

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

schema/content-descriptor.json

Lines changed: 4 additions & 0 deletions
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

Lines changed: 12 additions & 2 deletions
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,17 @@
7877
}
7978
}
8079
}
80+
},
81+
"annotations": {
82+
"id": "https://opencontainers.org/schema/image/annotations",
83+
"oneOf": [
84+
{
85+
"$ref": "defs.json#/definitions/mapStringString"
86+
},
87+
{
88+
"type": "null"
89+
}
90+
]
8191
}
8292
}
8393
},

0 commit comments

Comments
 (0)