mirror of https://github.com/docker/compose.git
Merge pull request #3039 from dbonev/3020-build-arguments-object-syntax
Allowing null for build args
This commit is contained in:
commit
7033042656
|
@ -58,20 +58,7 @@
|
|||
"properties": {
|
||||
"context": {"type": "string"},
|
||||
"dockerfile": {"type": "string"},
|
||||
"args": {
|
||||
"oneOf": [
|
||||
{"$ref": "#/definitions/list_of_strings"},
|
||||
{
|
||||
"type": "object",
|
||||
"patternProperties": {
|
||||
"^.+$": {
|
||||
"type": ["string", "number"]
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
]
|
||||
}
|
||||
"args": {"$ref": "#/definitions/list_or_dict"}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
|
|
|
@ -404,7 +404,7 @@ class ConfigTest(unittest.TestCase):
|
|||
config.load(config_details)
|
||||
assert (
|
||||
"services.web.build.args contains an invalid type, it should be an "
|
||||
"array, or an object" in exc.exconly()
|
||||
"object, or an array" in exc.exconly()
|
||||
)
|
||||
|
||||
def test_config_integer_service_name_raise_validation_error(self):
|
||||
|
@ -689,6 +689,31 @@ class ConfigTest(unittest.TestCase):
|
|||
assert service['build']['args']['opt1'] == '42'
|
||||
assert service['build']['args']['opt2'] == 'foobar'
|
||||
|
||||
def test_build_args_allow_empty_properties(self):
|
||||
service = config.load(
|
||||
build_config_details(
|
||||
{
|
||||
'version': '2',
|
||||
'services': {
|
||||
'web': {
|
||||
'build': {
|
||||
'context': '.',
|
||||
'dockerfile': 'Dockerfile-alt',
|
||||
'args': {
|
||||
'foo': None
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
'tests/fixtures/extends',
|
||||
'filename.yml'
|
||||
)
|
||||
).services[0]
|
||||
assert 'args' in service['build']
|
||||
assert 'foo' in service['build']['args']
|
||||
assert service['build']['args']['foo'] == 'None'
|
||||
|
||||
def test_load_with_multiple_files_mismatched_networks_format(self):
|
||||
base_file = config.ConfigFile(
|
||||
'base.yaml',
|
||||
|
|
Loading…
Reference in New Issue