Преглед на файлове

Fix a handful of issues with 3.2 schema

Signed-off-by: Joffrey F <[email protected]>
Joffrey F преди 8 години
родител
ревизия
7b19009511
променени са 3 файла, в които са добавени 12 реда и са изтрити 11 реда
  1. 6 5
      compose/config/config.py
  2. 2 3
      compose/config/config_schema_v3.2.json
  3. 4 3
      compose/config/serialize.py

+ 6 - 5
compose/config/config.py

@@ -490,11 +490,12 @@ def process_config_file(config_file, environment, service_name=None):
             config_file.get_networks(),
             'network',
             environment)
-        processed_config['secrets'] = interpolate_config_section(
-            config_file,
-            config_file.get_secrets(),
-            'secrets',
-            environment)
+        if config_file.version in (const.COMPOSEFILE_V3_1, const.COMPOSEFILE_V3_2):
+            processed_config['secrets'] = interpolate_config_section(
+                config_file,
+                config_file.get_secrets(),
+                'secrets',
+                environment)
     else:
         processed_config = services
 

+ 2 - 3
compose/config/config_schema_v3.2.json

@@ -1,6 +1,6 @@
 {
   "$schema": "http://json-schema.org/draft-04/schema#",
-  "id": "config_schema_v3.1.json",
+  "id": "config_schema_v3.2.json",
   "type": "object",
   "required": ["version"],
 
@@ -169,8 +169,7 @@
           "type": "array",
           "items": {
             "oneOf": [
-              {"type": "number", "format": "ports"},
-              {"type": "string", "format": "ports"},
+              {"type": ["string", "number"], "format": "ports"},
               {
                 "type": "object",
                 "properties": {

+ 4 - 3
compose/config/serialize.py

@@ -4,10 +4,11 @@ from __future__ import unicode_literals
 import six
 import yaml
 
-from compose import const
 from compose.config import types
 from compose.const import COMPOSEFILE_V1 as V1
 from compose.const import COMPOSEFILE_V2_1 as V2_1
+from compose.const import COMPOSEFILE_V3_1 as V3_1
+from compose.const import COMPOSEFILE_V3_1 as V3_2
 
 
 def serialize_config_type(dumper, data):
@@ -45,7 +46,7 @@ def denormalize_config(config):
         if 'external_name' in vol_conf:
             del vol_conf['external_name']
 
-    if config.version in (V3_1,):
+    if config.version in (V3_1, V3_2):
         result['secrets'] = config.secrets
     return result
 
@@ -103,7 +104,7 @@ def denormalize_service_dict(service_dict, version):
                 service_dict['healthcheck']['timeout']
             )
 
-    if 'ports' in service_dict and version < const.COMPOSEFILE_V3_2:
+    if 'ports' in service_dict and version not in (V3_2,):
         service_dict['ports'] = map(
             lambda p: p.legacy_repr() if isinstance(p, types.ServicePort) else p,
             service_dict['ports']