mirror of https://github.com/docker/compose.git
Raise configuration error when trying to extend service that does not exist. Fixes #1826
Signed-off-by: Karol Duleba <mr.fuxi@gmail.com>
This commit is contained in:
parent
7d5e26bd37
commit
2e7f08c2ef
|
@ -186,8 +186,16 @@ class ServiceLoader(object):
|
|||
already_seen=other_already_seen,
|
||||
)
|
||||
|
||||
base_service = extends_options['service']
|
||||
other_config = load_yaml(other_config_path)
|
||||
other_service_dict = other_config[extends_options['service']]
|
||||
|
||||
if base_service not in other_config:
|
||||
msg = (
|
||||
"Cannot extend service '%s' in %s: Service not found"
|
||||
) % (base_service, other_config_path)
|
||||
raise ConfigurationError(msg)
|
||||
|
||||
other_service_dict = other_config[base_service]
|
||||
other_loader.detect_cycle(extends_options['service'])
|
||||
other_service_dict = other_loader.make_service_dict(
|
||||
service_dict['name'],
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
web:
|
||||
image: busybox
|
||||
extends:
|
||||
service: foo
|
|
@ -917,6 +917,11 @@ class ExtendsTest(unittest.TestCase):
|
|||
},
|
||||
])
|
||||
|
||||
def test_load_throws_error_when_base_service_does_not_exist(self):
|
||||
err_msg = r'''Cannot extend service 'foo' in .*: Service not found'''
|
||||
with self.assertRaisesRegexp(ConfigurationError, err_msg):
|
||||
load_from_filename('tests/fixtures/extends/nonexistent-service.yml')
|
||||
|
||||
|
||||
class BuildPathTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
|
|
Loading…
Reference in New Issue