mirror of https://github.com/docker/compose.git
Merge pull request #4714 from shin-/4707-fix-config-python3
Fix serializer bug (python 3)
This commit is contained in:
commit
b5ed31e4f5
|
@ -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,):
|
||||
service_dict['ports'] = map(
|
||||
lambda p: p.legacy_repr() if isinstance(p, types.ServicePort) else p,
|
||||
service_dict['ports']
|
||||
)
|
||||
service_dict['ports'] = [
|
||||
p.legacy_repr() if isinstance(p, types.ServicePort) else p
|
||||
for p in service_dict['ports']
|
||||
]
|
||||
|
||||
return service_dict
|
||||
|
|
|
@ -3837,3 +3837,15 @@ class SerializeTest(unittest.TestCase):
|
|||
serialized_service = serialized_config['services']['web']
|
||||
assert secret_sort(serialized_service['secrets']) == secret_sort(service_dict['secrets'])
|
||||
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']
|
||||
|
|
Loading…
Reference in New Issue