Avoid overriding external = False in serializer

Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
Joffrey F 2018-07-09 15:28:32 -04:00
parent 40631f9a01
commit 9c2ffe6384
2 changed files with 17 additions and 1 deletions

View File

@ -78,7 +78,7 @@ def denormalize_config(config, image_digests=None):
config.version >= V3_0 and config.version < v3_introduced_name_key(key)):
del conf['name']
elif 'external' in conf:
conf['external'] = True
conf['external'] = bool(conf['external'])
if 'attachable' in conf and config.version < V3_2:
# For compatibility mode, this option is invalid in v2

View File

@ -5096,3 +5096,19 @@ class SerializeTest(unittest.TestCase):
serialized_config = yaml.load(serialize_config(config_dict))
serialized_service = serialized_config['services']['web']
assert serialized_service['command'] == 'echo 十六夜 咲夜'
def test_serialize_external_false(self):
cfg = {
'version': '3.4',
'volumes': {
'test': {
'name': 'test-false',
'external': False
}
}
}
config_dict = config.load(build_config_details(cfg))
serialized_config = yaml.load(serialize_config(config_dict))
serialized_volume = serialized_config['volumes']['test']
assert serialized_volume['external'] is False