diff --git a/schema/README.md b/schema/README.md index 01a3e5ed8..f2a31d07d 100644 --- a/schema/README.md +++ b/schema/README.md @@ -2,13 +2,14 @@ ## 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 @@ -16,8 +17,8 @@ The layout of the files is as follows: ## 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` @@ -35,5 +36,5 @@ make validate Then use it like: ```bash -./validate schema.json /config.json +./validate config-schema.json /config.json ``` diff --git a/schema/schema-linux.json b/schema/config-linux.json similarity index 100% rename from schema/schema-linux.json rename to schema/config-linux.json diff --git a/schema/schema.json b/schema/config-schema.json similarity index 92% rename from schema/schema.json rename to schema/config-schema.json index adfda62fd..351901ad0 100644 --- a/schema/schema.json +++ b/schema/config-schema.json @@ -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", @@ -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", @@ -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": [ diff --git a/schema/schema-solaris.json b/schema/config-solaris.json similarity index 100% rename from schema/schema-solaris.json rename to schema/config-solaris.json diff --git a/schema/defs.json b/schema/defs.json index a1a9e8777..329031848 100644 --- a/schema/defs.json +++ b/schema/defs.json @@ -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" + } + ] } } } diff --git a/schema/state-schema.json b/schema/state-schema.json new file mode 100644 index 000000000..4a14f89bd --- /dev/null +++ b/schema/state-schema.json @@ -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" + ] +}