Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2221 allow empty environment keys #2225

Merged
merged 2 commits into from
Oct 19, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compose/config/fields_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"type": "object",
"patternProperties": {
"^[^-]+$": {
"type": ["string", "number", "boolean"],
"type": ["string", "number", "boolean", "null"],
"format": "environment"
}
},
Expand Down
3 changes: 1 addition & 2 deletions compose/config/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def _parse_valid_types_from_validator(validator):
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,
Expand All @@ -163,7 +163,6 @@ def _parse_oneof_validator(error):
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
Expand Down
17 changes: 17 additions & 0 deletions tests/unit/config/config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,23 @@ def test_invalid_interpolation(self):
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):
Expand Down