Browse Source

driver_opts can only be of type string

Signed-off-by: Joffrey F <[email protected]>
Joffrey F 9 years ago
parent
commit
d78ea85301
2 changed files with 15 additions and 1 deletions
  1. 1 1
      compose/config/fields_schema_v2.0.json
  2. 14 0
      tests/unit/config/config_test.py

+ 1 - 1
compose/config/fields_schema_v2.0.json

@@ -78,7 +78,7 @@
         "driver_opts": {
           "type": "object",
           "patternProperties": {
-            "^.+$": {"type": ["string", "number"]}
+            "^.+$": {"type": "string"}
           }
         },
         "external": {

+ 14 - 0
tests/unit/config/config_test.py

@@ -231,6 +231,20 @@ class ConfigTest(unittest.TestCase):
         assert volumes['simple'] == {}
         assert volumes['other'] == {}
 
+    def test_volume_invalid_driver_opt(self):
+        config_details = build_config_details({
+            'version': '2',
+            'services': {
+                'simple': {'image': 'busybox'}
+            },
+            'volumes': {
+                'simple': {'driver_opts': {'size': 42}},
+            }
+        })
+        with pytest.raises(ConfigurationError) as exc:
+            config.load(config_details)
+        assert 'driver_opts.size contains an invalid type' in exc.exconly()
+
     def test_load_service_with_name_version(self):
         with mock.patch('compose.config.config.log') as mock_logging:
             config_data = config.load(