Merge pull request #2225 from mnowster/2221-blank-env-vars

2221 allow empty environment keys
This commit is contained in:
Daniel Nephin 2015-10-19 14:06:31 -04:00
commit 3725c3ab7e
3 changed files with 19 additions and 3 deletions

View File

@ -41,7 +41,7 @@
"type": "object",
"patternProperties": {
"^[^-]+$": {
"type": ["string", "number", "boolean"],
"type": ["string", "number", "boolean", "null"],
"format": "environment"
}
},

View File

@ -136,7 +136,7 @@ def process_errors(errors, service_name=None):
if len(validator) >= 2:
first_type = anglicize_validator(validator[0])
last_type = anglicize_validator(validator[-1])
types_from_validator = "{}{}".format(first_type, ", ".join(validator[1:-1]))
types_from_validator = ", ".join([first_type] + validator[1:-1])
msg = "{} or {}".format(
types_from_validator,
@ -156,7 +156,6 @@ def process_errors(errors, service_name=None):
Inspecting the context value of a ValidationError gives us information about
which sub schema failed and which kind of error it is.
"""
required = [context for context in error.context if context.validator == 'required']
if required:
return required[0].message

View File

@ -449,6 +449,23 @@ class InterpolationTest(unittest.TestCase):
self.assertIn('in service "web"', cm.exception.msg)
self.assertIn('"${"', cm.exception.msg)
def test_empty_environment_key_allowed(self):
service_dict = config.load(
build_config_details(
{
'web': {
'build': '.',
'environment': {
'POSTGRES_PASSWORD': ''
},
},
},
'.',
None,
)
)[0]
self.assertEquals(service_dict['environment']['POSTGRES_PASSWORD'], '')
class VolumeConfigTest(unittest.TestCase):
def test_no_binding(self):