Fix env vars with empty values.

Signed-off-by: Daniel Nephin <dnephin@gmail.com>
This commit is contained in:
Daniel Nephin 2016-02-24 15:36:21 -08:00
parent 507503cdfa
commit 3bad04649d
2 changed files with 6 additions and 3 deletions

View File

@ -823,7 +823,7 @@ def split_command(command):
def format_environment(environment):
def format_env(key, value):
if not value:
if value is None:
return key
return '{key}={value}'.format(key=key, value=value)
return [format_env(*var) for var in six.iteritems(environment)]

View File

@ -374,11 +374,14 @@ class CreateContainerTest(helpers.BaseTestCase):
container = self.client.create_container(
BUSYBOX,
['echo'],
environment={'Foo': None, 'Other': 'one'},
environment={'Foo': None, 'Other': 'one', 'Blank': ''},
)
self.tmp_containers.append(container['Id'])
config = self.client.inspect_container(container['Id'])
assert sorted(config['Config']['Env']) == sorted(['Foo', 'Other=one'])
assert (
sorted(config['Config']['Env']) ==
sorted(['Foo', 'Other=one', 'Blank='])
)
class VolumeBindTest(helpers.BaseTestCase):