mirror of
https://github.com/docker/compose.git
synced 2025-07-27 07:34:10 +02:00
Get extended config path
Refactored out into it's own function. Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
This commit is contained in:
parent
538a501eec
commit
37bf8235b7
@ -179,6 +179,9 @@ class ServiceLoader(object):
|
|||||||
self.filename
|
self.filename
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.extended_config_path = self.get_extended_config_path(
|
||||||
|
self.service_dict['extends']
|
||||||
|
)
|
||||||
|
|
||||||
def detect_cycle(self, name):
|
def detect_cycle(self, name):
|
||||||
if self.signature(name) in self.already_seen:
|
if self.signature(name) in self.already_seen:
|
||||||
@ -215,11 +218,7 @@ class ServiceLoader(object):
|
|||||||
extends_options = self.service_dict['extends']
|
extends_options = self.service_dict['extends']
|
||||||
service_name = self.service_dict['name']
|
service_name = self.service_dict['name']
|
||||||
|
|
||||||
if 'file' in extends_options:
|
other_config_path = self.get_extended_config_path(extends_options)
|
||||||
extends_from_filename = extends_options['file']
|
|
||||||
other_config_path = expand_path(self.working_dir, extends_from_filename)
|
|
||||||
else:
|
|
||||||
other_config_path = self.filename
|
|
||||||
|
|
||||||
other_working_dir = os.path.dirname(other_config_path)
|
other_working_dir = os.path.dirname(other_config_path)
|
||||||
other_already_seen = self.already_seen + [self.signature(service_name)]
|
other_already_seen = self.already_seen + [self.signature(service_name)]
|
||||||
@ -252,6 +251,18 @@ class ServiceLoader(object):
|
|||||||
|
|
||||||
return merge_service_dicts(other_service_dict, self.service_dict)
|
return merge_service_dicts(other_service_dict, self.service_dict)
|
||||||
|
|
||||||
|
def get_extended_config_path(self, extends_options):
|
||||||
|
"""
|
||||||
|
Service we are extending either has a value for 'file' set, which we
|
||||||
|
need to obtain a full path too or we are extending from a service
|
||||||
|
defined in our own file.
|
||||||
|
"""
|
||||||
|
if 'file' in extends_options:
|
||||||
|
extends_from_filename = extends_options['file']
|
||||||
|
return expand_path(self.working_dir, extends_from_filename)
|
||||||
|
|
||||||
|
return self.filename
|
||||||
|
|
||||||
def signature(self, name):
|
def signature(self, name):
|
||||||
return (self.filename, name)
|
return (self.filename, name)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user