mirror of https://github.com/docker/compose.git
Fix port serialization with external IP
Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
4813494717
commit
7aa51a18ff
|
@ -151,9 +151,10 @@ def denormalize_service_dict(service_dict, version, image_digest=None):
|
|||
service_dict['healthcheck']['start_period'] = serialize_ns_time_value(
|
||||
service_dict['healthcheck']['start_period']
|
||||
)
|
||||
if 'ports' in service_dict and version < V3_2:
|
||||
|
||||
if 'ports' in service_dict:
|
||||
service_dict['ports'] = [
|
||||
p.legacy_repr() if isinstance(p, types.ServicePort) else p
|
||||
p.legacy_repr() if p.external_ip or version < V3_2 else p
|
||||
for p in service_dict['ports']
|
||||
]
|
||||
if 'volumes' in service_dict and (version < V2_3 or (version > V3_0 and version < V3_2)):
|
||||
|
|
|
@ -4943,6 +4943,18 @@ class SerializeTest(unittest.TestCase):
|
|||
serialized_config = yaml.load(serialize_config(config_dict))
|
||||
assert '8080:80/tcp' in serialized_config['services']['web']['ports']
|
||||
|
||||
def test_serialize_ports_with_ext_ip(self):
|
||||
config_dict = config.Config(version=V3_5, services=[
|
||||
{
|
||||
'ports': [types.ServicePort('80', '8080', None, None, '127.0.0.1')],
|
||||
'image': 'alpine',
|
||||
'name': 'web'
|
||||
}
|
||||
], volumes={}, networks={}, secrets={}, configs={})
|
||||
|
||||
serialized_config = yaml.load(serialize_config(config_dict))
|
||||
assert '127.0.0.1:8080:80/tcp' in serialized_config['services']['web']['ports']
|
||||
|
||||
def test_serialize_configs(self):
|
||||
service_dict = {
|
||||
'image': 'example/web',
|
||||
|
|
Loading…
Reference in New Issue