Environment keys can contain empty values

Environment keys that contain no value, get populated with values taken
from the environment not from the build phase but from running the command `up`.

Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
This commit is contained in:
Mazz Mosley 2015-10-19 15:15:24 +01:00 committed by Daniel Nephin
parent 5fdb75b541
commit 0e4f9c9a66
3 changed files with 19 additions and 2 deletions

View File

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

View File

@ -136,7 +136,7 @@ def process_errors(errors, service_name=None):
if len(validator) >= 2: if len(validator) >= 2:
first_type = anglicize_validator(validator[0]) first_type = anglicize_validator(validator[0])
last_type = anglicize_validator(validator[-1]) last_type = anglicize_validator(validator[-1])
types_from_validator = "{}".format(", ".join([first_type] + validator[1:-1])) types_from_validator = ", ".join([first_type] + validator[1:-1])
msg = "{} or {}".format( msg = "{} or {}".format(
types_from_validator, types_from_validator,

View File

@ -449,6 +449,23 @@ class InterpolationTest(unittest.TestCase):
self.assertIn('in service "web"', cm.exception.msg) self.assertIn('in service "web"', cm.exception.msg)
self.assertIn('"${"', 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): class VolumeConfigTest(unittest.TestCase):
def test_no_binding(self): def test_no_binding(self):