Merge v1 config jsonschemas into a single file.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
Daniel Nephin 2016-02-05 20:21:58 -05:00
parent adb64ef8d5
commit be554c3a74
4 changed files with 28 additions and 40 deletions

View File

@ -1,13 +1,16 @@
{ {
"$schema": "http://json-schema.org/draft-04/schema#", "$schema": "http://json-schema.org/draft-04/schema#",
"id": "service_schema_v1.json", "id": "config_schema_v1.json",
"type": "object", "type": "object",
"allOf": [ "patternProperties": {
{"$ref": "#/definitions/service"}, "^[a-zA-Z0-9._-]+$": {
{"$ref": "#/definitions/constraints"} "$ref": "#/definitions/service"
], }
},
"additionalProperties": false,
"definitions": { "definitions": {
"service": { "service": {
@ -162,21 +165,24 @@
{"type": "array", "items": {"type": "string"}, "uniqueItems": true} {"type": "array", "items": {"type": "string"}, "uniqueItems": true}
] ]
}, },
"constraints": { "constraints": {
"id": "#/definitions/constraints", "services": {
"anyOf": [ "id": "#/definitions/services/constraints",
{ "anyOf": [
"required": ["build"], {
"not": {"required": ["image"]} "required": ["build"],
}, "not": {"required": ["image"]}
{ },
"required": ["image"], {
"not": {"anyOf": [ "required": ["image"],
{"required": ["build"]}, "not": {"anyOf": [
{"required": ["dockerfile"]} {"required": ["build"]},
]} {"required": ["dockerfile"]}
} ]}
] }
]
}
} }
} }
} }

View File

@ -1,13 +0,0 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"id": "fields_schema_v1.json",
"patternProperties": {
"^[a-zA-Z0-9._-]+$": {
"$ref": "service_schema_v1.json#/definitions/service"
}
},
"additionalProperties": false
}

View File

@ -388,7 +388,7 @@ def process_errors(errors, path_prefix=None):
def validate_against_config_schema(config_file): def validate_against_config_schema(config_file):
_validate_against_schema( _validate_against_schema(
config_file.config, config_file.config,
"service_schema_v{0}.json".format(config_file.version), "config_schema_v{0}.json".format(config_file.version),
format_checker=["ports", "expose", "bool-value-in-mapping"], format_checker=["ports", "expose", "bool-value-in-mapping"],
filename=config_file.filename) filename=config_file.filename)

View File

@ -18,13 +18,8 @@ exe = EXE(pyz,
a.datas, a.datas,
[ [
( (
'compose/config/fields_schema_v1.json', 'compose/config/config_schema_v1.json',
'compose/config/fields_schema_v1.json', 'compose/config/config_schema_v1.json',
'DATA'
),
(
'compose/config/service_schema_v1.json',
'compose/config/service_schema_v1.json',
'DATA' 'DATA'
), ),
( (