mirror of
https://github.com/docker/compose.git
synced 2025-07-23 13:45:00 +02:00
Fix ports reparsing for service extends
Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
6cbedb78cc
commit
0a55b07002
@ -266,6 +266,10 @@ class ServicePort(namedtuple('_ServicePort', 'target published protocol mode ext
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def parse(cls, spec):
|
def parse(cls, spec):
|
||||||
|
if isinstance(spec, cls):
|
||||||
|
# WHen extending a service with ports, the port definitions have already been parsed
|
||||||
|
return [spec]
|
||||||
|
|
||||||
if not isinstance(spec, dict):
|
if not isinstance(spec, dict):
|
||||||
result = []
|
result = []
|
||||||
for k, v in build_port_bindings([spec]).items():
|
for k, v in build_port_bindings([spec]).items():
|
||||||
|
@ -3403,7 +3403,7 @@ class ExtendsTest(unittest.TestCase):
|
|||||||
self.assertEqual(service[0]['command'], "top")
|
self.assertEqual(service[0]['command'], "top")
|
||||||
|
|
||||||
def test_extends_with_depends_on(self):
|
def test_extends_with_depends_on(self):
|
||||||
tmpdir = py.test.ensuretemp('test_extends_with_defined_version')
|
tmpdir = py.test.ensuretemp('test_extends_with_depends_on')
|
||||||
self.addCleanup(tmpdir.remove)
|
self.addCleanup(tmpdir.remove)
|
||||||
tmpdir.join('docker-compose.yml').write("""
|
tmpdir.join('docker-compose.yml').write("""
|
||||||
version: "2"
|
version: "2"
|
||||||
@ -3435,6 +3435,28 @@ class ExtendsTest(unittest.TestCase):
|
|||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
|
|
||||||
|
def test_extends_with_ports(self):
|
||||||
|
tmpdir = py.test.ensuretemp('test_extends_with_ports')
|
||||||
|
self.addCleanup(tmpdir.remove)
|
||||||
|
tmpdir.join('docker-compose.yml').write("""
|
||||||
|
version: '2'
|
||||||
|
|
||||||
|
services:
|
||||||
|
a:
|
||||||
|
image: nginx
|
||||||
|
ports:
|
||||||
|
- 80
|
||||||
|
|
||||||
|
b:
|
||||||
|
extends:
|
||||||
|
service: a
|
||||||
|
""")
|
||||||
|
services = load_from_filename(str(tmpdir.join('docker-compose.yml')))
|
||||||
|
|
||||||
|
assert len(services) == 2
|
||||||
|
for svc in services:
|
||||||
|
assert svc['ports'] == [types.ServicePort('80', None, None, None, None)]
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.xfail(IS_WINDOWS_PLATFORM, reason='paths use slash')
|
@pytest.mark.xfail(IS_WINDOWS_PLATFORM, reason='paths use slash')
|
||||||
class ExpandPathTest(unittest.TestCase):
|
class ExpandPathTest(unittest.TestCase):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user