mirror of https://github.com/docker/compose.git
0 is a valid value for a published port
Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
770d94376a
commit
1ae83d4139
|
@ -343,7 +343,7 @@ class ServicePort(namedtuple('_ServicePort', 'target published protocol mode ext
|
|||
def normalize_port_dict(port):
|
||||
return '{external_ip}{has_ext_ip}{published}{is_pub}{target}/{protocol}'.format(
|
||||
published=port.get('published', ''),
|
||||
is_pub=(':' if port.get('published') or port.get('external_ip') else ''),
|
||||
is_pub=(':' if port.get('published') is not None or port.get('external_ip') else ''),
|
||||
target=port.get('target'),
|
||||
protocol=port.get('protocol', 'tcp'),
|
||||
external_ip=port.get('external_ip', ''),
|
||||
|
|
|
@ -81,6 +81,12 @@ class TestServicePort(object):
|
|||
'external_ip': '1.1.1.1',
|
||||
}
|
||||
|
||||
def test_repr_published_port_0(self):
|
||||
port_def = '0:4000'
|
||||
ports = ServicePort.parse(port_def)
|
||||
assert len(ports) == 1
|
||||
assert ports[0].legacy_repr() == port_def + '/tcp'
|
||||
|
||||
def test_parse_port_range(self):
|
||||
ports = ServicePort.parse('25000-25001:4000-4001')
|
||||
assert len(ports) == 2
|
||||
|
|
Loading…
Reference in New Issue