Add config validation for service volumes, fixes #5352

Signed-off-by: Drew Romanyk <drewiswaycool@gmail.com>
This commit is contained in:
Drew Romanyk 2017-11-30 10:21:27 -06:00 committed by Joffrey F
parent 3ce2f03d70
commit dba2abd523
5 changed files with 31 additions and 0 deletions

View File

@ -245,6 +245,7 @@
{ {
"type": "object", "type": "object",
"required": ["type"], "required": ["type"],
"additionalProperties": false,
"properties": { "properties": {
"type": {"type": "string"}, "type": {"type": "string"},
"source": {"type": "string"}, "source": {"type": "string"},

View File

@ -278,6 +278,7 @@
{ {
"type": "object", "type": "object",
"required": ["type"], "required": ["type"],
"additionalProperties": false,
"properties": { "properties": {
"type": {"type": "string"}, "type": {"type": "string"},
"source": {"type": "string"}, "source": {"type": "string"},

View File

@ -282,6 +282,7 @@
{ {
"type": "object", "type": "object",
"required": ["type"], "required": ["type"],
"additionalProperties": false,
"properties": { "properties": {
"type": {"type": "string"}, "type": {"type": "string"},
"source": {"type": "string"}, "source": {"type": "string"},

View File

@ -282,6 +282,7 @@
{ {
"type": "object", "type": "object",
"required": ["type"], "required": ["type"],
"additionalProperties": false,
"properties": { "properties": {
"type": {"type": "string"}, "type": {"type": "string"},
"source": {"type": "string"}, "source": {"type": "string"},

View File

@ -2631,6 +2631,33 @@ class ConfigTest(unittest.TestCase):
] ]
assert service_sort(service_dicts) == service_sort(expected) assert service_sort(service_dicts) == service_sort(expected)
def test_service_volume_invalid_config(self):
config_details = build_config_details(
{
'version': '3.2',
'services': {
'web': {
'build': {
'context': '.',
'args': None,
},
'volumes': [
{
"type": "volume",
"source": "/data",
"garbage": {
"and": "error"
}
}
]
},
},
}
)
with pytest.raises(ConfigurationError) as exc:
config.load(config_details)
assert "services.web.volumes contains unsupported option: 'garbage'" in exc.exconly()
class NetworkModeTest(unittest.TestCase): class NetworkModeTest(unittest.TestCase):