浏览代码

expose array can contain either strings or numbers

Signed-off-by: Mazz Mosley <[email protected]>
Mazz Mosley 10 年之前
父节点
当前提交
7326608369
共有 2 个文件被更改,包括 20 次插入1 次删除
  1. 5 1
      compose/config/fields_schema.json
  2. 15 0
      tests/unit/config_test.py

+ 5 - 1
compose/config/fields_schema.json

@@ -42,7 +42,11 @@
           ]
         },
 
-        "expose": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
+        "expose": {
+          "type": "array",
+          "items": {"type": ["string", "number"]},
+          "uniqueItems": true
+        },
 
         "extends": {
           "type": "object",

+ 15 - 0
tests/unit/config_test.py

@@ -239,6 +239,21 @@ class ConfigTest(unittest.TestCase):
                 )
             )
 
+    def test_valid_config_which_allows_two_type_definitions(self):
+        expose_values = [["8000"], [8000]]
+        for expose in expose_values:
+            service = config.load(
+                config.ConfigDetails(
+                    {'web': {
+                        'image': 'busybox',
+                        'expose': expose
+                    }},
+                    'working_dir',
+                    'filename.yml'
+                )
+            )
+            self.assertEqual(service[0]['expose'], expose)
+
 
 class InterpolationTest(unittest.TestCase):
     @mock.patch.dict(os.environ)