external volume disallows other config keys

Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
Joffrey F 2016-01-13 13:52:59 -08:00
parent d601199eb5
commit e76b2679eb
2 changed files with 38 additions and 17 deletions

View File

@ -32,24 +32,32 @@
"definitions": { "definitions": {
"volume": { "volume": {
"id": "#/definitions/volume", "id": "#/definitions/volume",
"type": "object", "oneOf": [{
"properties": { "type": "object",
"driver": {"type": "string"}, "properties": {
"driver_opts": { "driver": {"type": "string"},
"type": "object", "driver_opts": {
"patternProperties": { "type": "object",
"^.+$": {"type": ["string", "number"]} "patternProperties": {
}, "^.+$": {"type": ["string", "number"]}
"additionalProperties": false },
"additionalProperties": false
}
}, },
"external": { "additionalProperties": false
"type": ["boolean", "object"], }, {
"properties": { "type": "object",
"name": {"type": "string"} "properties": {
}, "external": {
"additionalProperties": false "type": ["boolean", "object"],
} "properties": {
} "name": {"type": "string"}
},
"additionalProperties": false
}
},
"additionalProperties": false
}]
} }
}, },
"additionalProperties": false "additionalProperties": false

View File

@ -793,6 +793,19 @@ class ConfigTest(unittest.TestCase):
assert 'ext2' in volumes assert 'ext2' in volumes
assert volumes['ext2']['external']['name'] == 'aliased' assert volumes['ext2']['external']['name'] == 'aliased'
def test_external_volume_invalid_config(self):
config_details = build_config_details({
'version': 2,
'services': {
'bogus': {'image': 'busybox'}
},
'volumes': {
'ext': {'external': True, 'driver': 'foo'}
}
})
with self.assertRaises(ConfigurationError):
config.load(config_details)
class PortsTest(unittest.TestCase): class PortsTest(unittest.TestCase):
INVALID_PORTS_TYPES = [ INVALID_PORTS_TYPES = [