'file' key can be omitted from extends

If the 'file' key is not set in the extends_options dict then we
look for the 'service' from within the same file.

Fixes this issue: https://github.com/docker/compose/issues/1237

Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
This commit is contained in:
Mazz Mosley 2015-07-02 15:31:38 +01:00
commit 6e4a954dbd
3 changed files with 39 additions and 1 deletions

View file

@ -163,7 +163,12 @@ class ServiceLoader(object):
if self.working_dir is None:
raise Exception("No working_dir passed to ServiceLoader()")
other_config_path = expand_path(self.working_dir, extends_options['file'])
try:
extends_from_filename = extends_options['file']
except KeyError:
extends_from_filename = os.path.split(self.filename)[1]
other_config_path = expand_path(self.working_dir, extends_from_filename)
other_working_dir = os.path.dirname(other_config_path)
other_already_seen = self.already_seen + [self.signature(service_dict['name'])]
other_loader = ServiceLoader(