mirror of https://github.com/docker/compose.git
Add support for extension fields in v2.x and v3.4
Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
42aa1c3447
commit
8c6f2217c4
|
@ -41,6 +41,7 @@
|
|||
}
|
||||
},
|
||||
|
||||
"patternProperties": {"^x-": {}},
|
||||
"additionalProperties": false,
|
||||
|
||||
"definitions": {
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
}
|
||||
},
|
||||
|
||||
"patternProperties": {"^x-": {}},
|
||||
"additionalProperties": false,
|
||||
|
||||
"definitions": {
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
}
|
||||
},
|
||||
|
||||
"patternProperties": {"^x-": {}},
|
||||
"additionalProperties": false,
|
||||
|
||||
"definitions": {
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
}
|
||||
},
|
||||
|
||||
"patternProperties": {"^x-": {}},
|
||||
"additionalProperties": false,
|
||||
|
||||
"definitions": {
|
||||
|
|
|
@ -64,6 +64,7 @@
|
|||
}
|
||||
},
|
||||
|
||||
"patternProperties": {"^x-": {}},
|
||||
"additionalProperties": false,
|
||||
|
||||
"definitions": {
|
||||
|
|
|
@ -239,6 +239,16 @@ def handle_error_for_schema_with_id(error, path):
|
|||
invalid_config_key = parse_key_from_error_msg(error)
|
||||
return get_unsupported_config_msg(path, invalid_config_key)
|
||||
|
||||
if schema_id.startswith('config_schema_v'):
|
||||
invalid_config_key = parse_key_from_error_msg(error)
|
||||
return ('Invalid top-level property "{key}". Valid top-level '
|
||||
'sections for this Compose file are: {properties}, and '
|
||||
'extensions starting with "x-".\n\n{explanation}').format(
|
||||
key=invalid_config_key,
|
||||
properties=', '.join(error.schema['properties'].keys()),
|
||||
explanation=VERSION_EXPLANATION
|
||||
)
|
||||
|
||||
if not error.path:
|
||||
return '{}\n\n{}'.format(error.message, VERSION_EXPLANATION)
|
||||
|
||||
|
|
|
@ -251,7 +251,7 @@ class ConfigTest(unittest.TestCase):
|
|||
)
|
||||
)
|
||||
|
||||
assert 'Additional properties are not allowed' in excinfo.exconly()
|
||||
assert 'Invalid top-level property "web"' in excinfo.exconly()
|
||||
assert VERSION_EXPLANATION in excinfo.exconly()
|
||||
|
||||
def test_named_volume_config_empty(self):
|
||||
|
@ -773,6 +773,18 @@ class ConfigTest(unittest.TestCase):
|
|||
assert services[1]['name'] == 'db'
|
||||
assert services[2]['name'] == 'web'
|
||||
|
||||
def test_load_with_extensions(self):
|
||||
config_details = build_config_details({
|
||||
'version': '2.3',
|
||||
'x-data': {
|
||||
'lambda': 3,
|
||||
'excess': [True, {}]
|
||||
}
|
||||
})
|
||||
|
||||
config_data = config.load(config_details)
|
||||
assert config_data.services == []
|
||||
|
||||
def test_config_build_configuration(self):
|
||||
service = config.load(
|
||||
build_config_details(
|
||||
|
|
Loading…
Reference in New Issue