Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

schema/state.json: Add a JSON Schema for the state JSON #481

Merged
merged 4 commits into from
Jun 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions schema/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,23 @@

## Overview

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

The layout of the files is as follows:
* [schema.json](schema.json) - the primary entrypoint for the whole schema document
* [schema-linux.json](schema-linux.json) - this schema is for the Linux-specific sub-structure
* [schema-solaris.json](schema-solaris.json) - this schema is for the Solaris-specific sub-structure

* [config-schema.json](config.json) - the primary entrypoint for the [configuration](../config.md) schema
* [config-linux.json](config-linux.json) - the [Linux-specific configuration sub-structure](../config-linux.md)
* [config-solaris.json](config-solaris.json) - the [Solaris-specific configuration sub-structure](../config-solaris.md)
* [state-schema.json](state.json) - the primary entrypoint for the [state JSON](../runtime.md#state) schema
* [defs.json](defs.json) - definitions for general types
* [defs-linux.json](defs-linux.json) - definitions for Linux-specific types
* [validate.go](validate.go) - validation utility source code


## Utility

There is also included a simple utility for facilitating validation of a
`config.json`. To build it:
There is also included a simple utility for facilitating validation.
To build it:

```bash
export GOPATH=`mktemp -d`
Expand All @@ -35,5 +36,5 @@ make validate
Then use it like:

```bash
./validate schema.json <yourpath>/config.json
./validate config-schema.json <yourpath>/config.json
```
File renamed without changes.
17 changes: 4 additions & 13 deletions schema/schema.json → schema/config-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
"type": "object",
"properties": {
"ociVersion": {
"description": "The version of OpenContainer specification configuration complies with",
"id": "https://opencontainers.org/schema/bundle/ociVersion",
"type": "string"
"$ref": "defs.json#/definitions/ociVersion"
},
"hooks": {
"id": "https://opencontainers.org/schema/bundle/hooks",
Expand All @@ -25,15 +24,7 @@
}
},
"annotations": {
"id": "https://opencontainers.org/schema/bundle/annotations",
"oneOf": [
{
"$ref": "defs.json#/definitions/mapStringString"
},
{
"type": "null"
}
]
"$ref": "defs.json#/definitions/annotations"
},
"hostname": {
"id": "https://opencontainers.org/schema/bundle/hostname",
Expand Down Expand Up @@ -166,10 +157,10 @@
}
},
"linux": {
"$ref": "schema-linux.json#/linux"
"$ref": "config-linux.json#/linux"
},
"solaris": {
"$ref": "schema-solaris.json#/solaris"
"$ref": "config-solaris.json#/solaris"
}
},
"required": [
Expand Down
File renamed without changes.
14 changes: 14 additions & 0 deletions schema/defs.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,20 @@
"source",
"type"
]
},
"ociVersion": {
"description": "The version of Open Container Runtime Specification that the document complies with",
"type": "string"
},
"annotations": {
"oneOf": [
{
"$ref": "#/definitions/mapStringString"
},
{
"type": "null"
}
]
}
}
}
45 changes: 45 additions & 0 deletions schema/state-schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"description": "Open Container Runtime State Schema",
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "https://opencontainers.org/schema/state",
"type": "object",
"properties": {
"ociVersion": {
"id": "https://opencontainers.org/schema/runtime/state/ociVersion",
"$ref": "defs.json#/definitions/ociVersion"
},
"id": {
"id": "https://opencontainers.org/schema/runtime/state/id",
"description": "the container's ID",
"type": "string"
},
"status": {
"id": "https://opencontainers.org/schema/runtime/state/status",
"type": "string",
"enum": [
"created",
"running",
"stopped"
]
},
"pid": {
"id": "https://opencontainers.org/schema/runtime/state/pid",
"type": "integer",
"minimum": 0
},
"bundlePath": {
"id": "https://opencontainers.org/schema/runtime/state/bundlePath",
"type": "string"
},
"annotations": {
"$ref": "defs.json#/definitions/annotations"
}
},
"required": [
"ociVersion",
"id",
"status",
"pid",
"bundlePath"
]
}