Bläddra i källkod

Merge v1 config jsonschemas into a single file.

Signed-off-by: Daniel Nephin <[email protected]>
Daniel Nephin 9 år sedan
förälder
incheckning
be554c3a74

+ 25 - 19
compose/config/service_schema_v1.json → compose/config/config_schema_v1.json

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

+ 0 - 13
compose/config/fields_schema_v1.json

@@ -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
-}

+ 1 - 1
compose/config/validation.py

@@ -388,7 +388,7 @@ def process_errors(errors, path_prefix=None):
 def validate_against_config_schema(config_file):
     _validate_against_schema(
         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"],
         filename=config_file.filename)
 

+ 2 - 7
docker-compose.spec

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