Skip to content

Commit 2f0fa18

Browse files
committed
Merge pull request opencontainers#481 from wking/state-schema
schema/state.json: Add a JSON Schema for the state JSON
2 parents 79b26a1 + 2a5986f commit 2f0fa18

File tree

6 files changed

+72
-21
lines changed

6 files changed

+72
-21
lines changed

schema/README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,23 @@
22

33
## Overview
44

5-
This directory contains the [JSON Schema](http://json-schema.org/) for
6-
validating the `config.json` of this container runtime specification.
5+
This directory contains the [JSON Schema](http://json-schema.org/) for validating JSON covered by this specification.
76

87
The layout of the files is as follows:
9-
* [schema.json](schema.json) - the primary entrypoint for the whole schema document
10-
* [schema-linux.json](schema-linux.json) - this schema is for the Linux-specific sub-structure
11-
* [schema-solaris.json](schema-solaris.json) - this schema is for the Solaris-specific sub-structure
8+
9+
* [config-schema.json](config.json) - the primary entrypoint for the [configuration](../config.md) schema
10+
* [config-linux.json](config-linux.json) - the [Linux-specific configuration sub-structure](../config-linux.md)
11+
* [config-solaris.json](config-solaris.json) - the [Solaris-specific configuration sub-structure](../config-solaris.md)
12+
* [state-schema.json](state.json) - the primary entrypoint for the [state JSON](../runtime.md#state) schema
1213
* [defs.json](defs.json) - definitions for general types
1314
* [defs-linux.json](defs-linux.json) - definitions for Linux-specific types
1415
* [validate.go](validate.go) - validation utility source code
1516

1617

1718
## Utility
1819

19-
There is also included a simple utility for facilitating validation of a
20-
`config.json`. To build it:
20+
There is also included a simple utility for facilitating validation.
21+
To build it:
2122

2223
```bash
2324
export GOPATH=`mktemp -d`
@@ -35,5 +36,5 @@ make validate
3536
Then use it like:
3637

3738
```bash
38-
./validate schema.json <yourpath>/config.json
39+
./validate config-schema.json <yourpath>/config.json
3940
```
File renamed without changes.

schema/schema.json renamed to schema/config-schema.json

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
"type": "object",
66
"properties": {
77
"ociVersion": {
8-
"description": "The version of OpenContainer specification configuration complies with",
98
"id": "https://opencontainers.org/schema/bundle/ociVersion",
10-
"type": "string"
9+
"$ref": "defs.json#/definitions/ociVersion"
1110
},
1211
"hooks": {
1312
"id": "https://opencontainers.org/schema/bundle/hooks",
@@ -25,15 +24,7 @@
2524
}
2625
},
2726
"annotations": {
28-
"id": "https://opencontainers.org/schema/bundle/annotations",
29-
"oneOf": [
30-
{
31-
"$ref": "defs.json#/definitions/mapStringString"
32-
},
33-
{
34-
"type": "null"
35-
}
36-
]
27+
"$ref": "defs.json#/definitions/annotations"
3728
},
3829
"hostname": {
3930
"id": "https://opencontainers.org/schema/bundle/hostname",
@@ -166,10 +157,10 @@
166157
}
167158
},
168159
"linux": {
169-
"$ref": "schema-linux.json#/linux"
160+
"$ref": "config-linux.json#/linux"
170161
},
171162
"solaris": {
172-
"$ref": "schema-solaris.json#/solaris"
163+
"$ref": "config-solaris.json#/solaris"
173164
}
174165
},
175166
"required": [
File renamed without changes.

schema/defs.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,20 @@
155155
"source",
156156
"type"
157157
]
158+
},
159+
"ociVersion": {
160+
"description": "The version of Open Container Runtime Specification that the document complies with",
161+
"type": "string"
162+
},
163+
"annotations": {
164+
"oneOf": [
165+
{
166+
"$ref": "#/definitions/mapStringString"
167+
},
168+
{
169+
"type": "null"
170+
}
171+
]
158172
}
159173
}
160174
}

schema/state-schema.json

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"description": "Open Container Runtime State Schema",
3+
"$schema": "http://json-schema.org/draft-04/schema#",
4+
"id": "https://opencontainers.org/schema/state",
5+
"type": "object",
6+
"properties": {
7+
"ociVersion": {
8+
"id": "https://opencontainers.org/schema/runtime/state/ociVersion",
9+
"$ref": "defs.json#/definitions/ociVersion"
10+
},
11+
"id": {
12+
"id": "https://opencontainers.org/schema/runtime/state/id",
13+
"description": "the container's ID",
14+
"type": "string"
15+
},
16+
"status": {
17+
"id": "https://opencontainers.org/schema/runtime/state/status",
18+
"type": "string",
19+
"enum": [
20+
"created",
21+
"running",
22+
"stopped"
23+
]
24+
},
25+
"pid": {
26+
"id": "https://opencontainers.org/schema/runtime/state/pid",
27+
"type": "integer",
28+
"minimum": 0
29+
},
30+
"bundlePath": {
31+
"id": "https://opencontainers.org/schema/runtime/state/bundlePath",
32+
"type": "string"
33+
},
34+
"annotations": {
35+
"$ref": "defs.json#/definitions/annotations"
36+
}
37+
},
38+
"required": [
39+
"ociVersion",
40+
"id",
41+
"status",
42+
"pid",
43+
"bundlePath"
44+
]
45+
}

0 commit comments

Comments
 (0)