mirror of
https://github.com/docker/compose.git
synced 2025-07-26 07:04:32 +02:00
Some minor style cleanup
- fixed a docstring to make it PEP257 compliant - wrapped some long lines - used a more specific error Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
parent
0375dccf64
commit
a5959d9be2
@ -213,9 +213,16 @@ def load(config_details):
|
|||||||
|
|
||||||
|
|
||||||
class ServiceLoader(object):
|
class ServiceLoader(object):
|
||||||
def __init__(self, working_dir, filename, service_name, service_dict, already_seen=None):
|
def __init__(
|
||||||
|
self,
|
||||||
|
working_dir,
|
||||||
|
filename,
|
||||||
|
service_name,
|
||||||
|
service_dict,
|
||||||
|
already_seen=None
|
||||||
|
):
|
||||||
if working_dir is None:
|
if working_dir is None:
|
||||||
raise Exception("No working_dir passed to ServiceLoader()")
|
raise ValueError("No working_dir passed to ServiceLoader()")
|
||||||
|
|
||||||
self.working_dir = os.path.abspath(working_dir)
|
self.working_dir = os.path.abspath(working_dir)
|
||||||
|
|
||||||
@ -312,33 +319,33 @@ 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):
|
def get_extended_config_path(self, extends_options):
|
||||||
"""
|
"""Service we are extending either has a value for 'file' set, which we
|
||||||
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
|
need to obtain a full path too or we are extending from a service
|
||||||
defined in our own file.
|
defined in our own file.
|
||||||
"""
|
"""
|
||||||
if 'file' in extends_options:
|
if 'file' in extends_options:
|
||||||
extends_from_filename = extends_options['file']
|
return expand_path(self.working_dir, extends_options['file'])
|
||||||
return expand_path(self.working_dir, extends_from_filename)
|
|
||||||
|
|
||||||
return self.filename
|
return self.filename
|
||||||
|
|
||||||
def signature(self, name):
|
def signature(self, name):
|
||||||
return (self.filename, name)
|
return self.filename, name
|
||||||
|
|
||||||
|
|
||||||
def validate_extended_service_dict(service_dict, filename, service):
|
def validate_extended_service_dict(service_dict, filename, service):
|
||||||
error_prefix = "Cannot extend service '%s' in %s:" % (service, filename)
|
error_prefix = "Cannot extend service '%s' in %s:" % (service, filename)
|
||||||
|
|
||||||
if 'links' in service_dict:
|
if 'links' in service_dict:
|
||||||
raise ConfigurationError("%s services with 'links' cannot be extended" % error_prefix)
|
raise ConfigurationError(
|
||||||
|
"%s services with 'links' cannot be extended" % error_prefix)
|
||||||
|
|
||||||
if 'volumes_from' in service_dict:
|
if 'volumes_from' in service_dict:
|
||||||
raise ConfigurationError("%s services with 'volumes_from' cannot be extended" % error_prefix)
|
raise ConfigurationError(
|
||||||
|
"%s services with 'volumes_from' cannot be extended" % error_prefix)
|
||||||
|
|
||||||
if 'net' in service_dict:
|
if 'net' in service_dict:
|
||||||
if get_service_name_from_net(service_dict['net']) is not None:
|
if get_service_name_from_net(service_dict['net']) is not None:
|
||||||
raise ConfigurationError("%s services with 'net: container' cannot be extended" % error_prefix)
|
raise ConfigurationError(
|
||||||
|
"%s services with 'net: container' cannot be extended" % error_prefix)
|
||||||
|
|
||||||
|
|
||||||
def process_container_options(service_dict, working_dir=None):
|
def process_container_options(service_dict, working_dir=None):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user