From 59ede1a6ac23ed10d6b644afc1e8cb45a57aa62e Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Wed, 1 Jun 2016 15:39:16 -0700 Subject: [PATCH 1/4] schema: Move schema.json -> config-schema.json and similar To make it clear that these schemas are for validating config.json (and not, for example, state JSON). I've left the IDs alone for now, because my PR adjusting those was rejected [1]. The rule for the -schema portion is "use it for entrypoint files" [2]. [1]: https://github.com/opencontainers/runtime-spec/pull/453 [2]: https://github.com/opencontainers/runtime-spec/pull/481#issuecomment-223641814 Signed-off-by: W. Trevor King --- schema/README.md | 16 ++++++++-------- schema/{schema-linux.json => config-linux.json} | 0 schema/{schema.json => config-schema.json} | 4 ++-- .../{schema-solaris.json => config-solaris.json} | 0 4 files changed, 10 insertions(+), 10 deletions(-) rename schema/{schema-linux.json => config-linux.json} (100%) rename schema/{schema.json => config-schema.json} (98%) rename schema/{schema-solaris.json => config-solaris.json} (100%) diff --git a/schema/README.md b/schema/README.md index 01a3e5ed8..eb87d29e3 100644 --- a/schema/README.md +++ b/schema/README.md @@ -2,13 +2,13 @@ ## 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) * [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 +16,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 +35,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 98% rename from schema/schema.json rename to schema/config-schema.json index adfda62fd..5bc8db35d 100644 --- a/schema/schema.json +++ b/schema/config-schema.json @@ -166,10 +166,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 From 28cbd4dd8eda7f3e17d2dcaac6b381d0e2a6591f Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Wed, 1 Jun 2016 15:46:17 -0700 Subject: [PATCH 2/4] schema/defs.json: Pull ociVersion over from config-schema.json So we can use it in the coming state-schema.json without duplication. While I'm touching it, I updated the spec title to match the project README's header. I also dropped the "id" because none of the other defs.json entries had an ID. Signed-off-by: W. Trevor King --- schema/config-schema.json | 3 +-- schema/defs.json | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/schema/config-schema.json b/schema/config-schema.json index 5bc8db35d..439672033 100644 --- a/schema/config-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", diff --git a/schema/defs.json b/schema/defs.json index a1a9e8777..28cbe6f15 100644 --- a/schema/defs.json +++ b/schema/defs.json @@ -155,6 +155,10 @@ "source", "type" ] + }, + "ociVersion": { + "description": "The version of Open Container Runtime Specification that the document complies with", + "type": "string" } } } From a3126aa342da58695e9865fbfe754c4ba0a94e06 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Mon, 6 Jun 2016 09:54:28 -0700 Subject: [PATCH 3/4] schema/defs.json: Pull annotations over from config-schema.json So we can use it in the coming state-schema.json without duplication. I dropped the "id" because none of the other defs.json entries had an ID. Signed-off-by: W. Trevor King --- schema/config-schema.json | 10 +--------- schema/defs.json | 10 ++++++++++ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/schema/config-schema.json b/schema/config-schema.json index 439672033..351901ad0 100644 --- a/schema/config-schema.json +++ b/schema/config-schema.json @@ -24,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", diff --git a/schema/defs.json b/schema/defs.json index 28cbe6f15..329031848 100644 --- a/schema/defs.json +++ b/schema/defs.json @@ -159,6 +159,16 @@ "ociVersion": { "description": "The version of Open Container Runtime Specification that the document complies with", "type": "string" + }, + "annotations": { + "oneOf": [ + { + "$ref": "#/definitions/mapStringString" + }, + { + "type": "null" + } + ] } } } From 2a5986f7d6560fe2f99a6c2cc8b2c5042c9488d7 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Wed, 1 Jun 2016 15:53:57 -0700 Subject: [PATCH 4/4] schema/state-schema.json: Add a JSON Schema for the state JSON The IDs namespace the fields within the OCI, with /runtime to select the opencontainers/runtime-spec project, and /state to select the state JSON within runtime-spec. Signed-off-by: W. Trevor King --- schema/README.md | 1 + schema/state-schema.json | 45 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 schema/state-schema.json diff --git a/schema/README.md b/schema/README.md index eb87d29e3..f2a31d07d 100644 --- a/schema/README.md +++ b/schema/README.md @@ -9,6 +9,7 @@ The layout of the files is as follows: * [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 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" + ] +}