Merge pull request #4714 from shin-/4707-fix-config-python3

Fix serializer bug (python 3)
This commit is contained in:
Joffrey F 2017-04-10 12:20:52 -07:00 committed by GitHub
commit b5ed31e4f5
2 changed files with 16 additions and 4 deletions

View File

@ -111,9 +111,9 @@ def denormalize_service_dict(service_dict, version, image_digest=None):
) )
if 'ports' in service_dict and version not in (V3_2,): if 'ports' in service_dict and version not in (V3_2,):
service_dict['ports'] = map( service_dict['ports'] = [
lambda p: p.legacy_repr() if isinstance(p, types.ServicePort) else p, p.legacy_repr() if isinstance(p, types.ServicePort) else p
service_dict['ports'] for p in service_dict['ports']
) ]
return service_dict return service_dict

View File

@ -3837,3 +3837,15 @@ class SerializeTest(unittest.TestCase):
serialized_service = serialized_config['services']['web'] serialized_service = serialized_config['services']['web']
assert secret_sort(serialized_service['secrets']) == secret_sort(service_dict['secrets']) assert secret_sort(serialized_service['secrets']) == secret_sort(service_dict['secrets'])
assert 'secrets' in serialized_config assert 'secrets' in serialized_config
def test_serialize_ports(self):
config_dict = config.Config(version='2.0', services=[
{
'ports': [types.ServicePort('80', '8080', None, None, None)],
'image': 'alpine',
'name': 'web'
}
], volumes={}, networks={}, secrets={})
serialized_config = yaml.load(serialize_config(config_dict))
assert '8080:80/tcp' in serialized_config['services']['web']['ports']