mirror of https://github.com/docker/compose.git
Split out compose.config.errors
Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
This commit is contained in:
parent
92ef1f5702
commit
31ac3ce22a
|
@ -8,6 +8,12 @@ import six
|
||||||
|
|
||||||
from compose.cli.utils import find_candidates_in_parent_dirs
|
from compose.cli.utils import find_candidates_in_parent_dirs
|
||||||
|
|
||||||
|
from .errors import (
|
||||||
|
ConfigurationError,
|
||||||
|
CircularReference,
|
||||||
|
ComposeFileNotFound,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
DOCKER_CONFIG_KEYS = [
|
DOCKER_CONFIG_KEYS = [
|
||||||
'cap_add',
|
'cap_add',
|
||||||
|
@ -536,33 +542,3 @@ def load_yaml(filename):
|
||||||
return yaml.safe_load(fh)
|
return yaml.safe_load(fh)
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
raise ConfigurationError(six.text_type(e))
|
raise ConfigurationError(six.text_type(e))
|
||||||
|
|
||||||
|
|
||||||
class ConfigurationError(Exception):
|
|
||||||
def __init__(self, msg):
|
|
||||||
self.msg = msg
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return self.msg
|
|
||||||
|
|
||||||
|
|
||||||
class CircularReference(ConfigurationError):
|
|
||||||
def __init__(self, trail):
|
|
||||||
self.trail = trail
|
|
||||||
|
|
||||||
@property
|
|
||||||
def msg(self):
|
|
||||||
lines = [
|
|
||||||
"{} in {}".format(service_name, filename)
|
|
||||||
for (filename, service_name) in self.trail
|
|
||||||
]
|
|
||||||
return "Circular reference:\n {}".format("\n extends ".join(lines))
|
|
||||||
|
|
||||||
|
|
||||||
class ComposeFileNotFound(ConfigurationError):
|
|
||||||
def __init__(self, supported_filenames):
|
|
||||||
super(ComposeFileNotFound, self).__init__("""
|
|
||||||
Can't find a suitable configuration file in this directory or any parent. Are you in the right directory?
|
|
||||||
|
|
||||||
Supported filenames: %s
|
|
||||||
""" % ", ".join(supported_filenames))
|
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
class ConfigurationError(Exception):
|
||||||
|
def __init__(self, msg):
|
||||||
|
self.msg = msg
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.msg
|
||||||
|
|
||||||
|
|
||||||
|
class CircularReference(ConfigurationError):
|
||||||
|
def __init__(self, trail):
|
||||||
|
self.trail = trail
|
||||||
|
|
||||||
|
@property
|
||||||
|
def msg(self):
|
||||||
|
lines = [
|
||||||
|
"{} in {}".format(service_name, filename)
|
||||||
|
for (filename, service_name) in self.trail
|
||||||
|
]
|
||||||
|
return "Circular reference:\n {}".format("\n extends ".join(lines))
|
||||||
|
|
||||||
|
|
||||||
|
class ComposeFileNotFound(ConfigurationError):
|
||||||
|
def __init__(self, supported_filenames):
|
||||||
|
super(ComposeFileNotFound, self).__init__("""
|
||||||
|
Can't find a suitable configuration file in this directory or any parent. Are you in the right directory?
|
||||||
|
|
||||||
|
Supported filenames: %s
|
||||||
|
""" % ", ".join(supported_filenames))
|
Loading…
Reference in New Issue