mirror of https://github.com/docker/compose.git
Remove flake8 ignores and wrap the longest lines to 140 char.
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
This commit is contained in:
parent
fc63454c99
commit
54973e8200
|
@ -30,7 +30,11 @@ DOCKER_CONFIG_HINTS = {
|
|||
VALID_NAME_CHARS = '[a-zA-Z0-9\._\-]'
|
||||
|
||||
|
||||
@FormatChecker.cls_checks(format="ports", raises=ValidationError("Invalid port formatting, it should be '[[remote_ip:]remote_port:]port[/protocol]'"))
|
||||
@FormatChecker.cls_checks(
|
||||
format="ports",
|
||||
raises=ValidationError(
|
||||
"Invalid port formatting, it should be "
|
||||
"'[[remote_ip:]remote_port:]port[/protocol]'"))
|
||||
def format_ports(instance):
|
||||
try:
|
||||
split_port(instance)
|
||||
|
@ -122,9 +126,14 @@ def process_errors(errors):
|
|||
invalid_keys.append(get_unsupported_config_msg(service_name, invalid_config_key))
|
||||
elif error.validator == 'anyOf':
|
||||
if 'image' in error.instance and 'build' in error.instance:
|
||||
required.append("Service '{}' has both an image and build path specified. A service can either be built to image or use an existing image, not both.".format(service_name))
|
||||
required.append(
|
||||
"Service '{}' has both an image and build path specified. "
|
||||
"A service can either be built to image or use an existing "
|
||||
"image, not both.".format(service_name))
|
||||
elif 'image' not in error.instance and 'build' not in error.instance:
|
||||
required.append("Service '{}' has neither an image nor a build path specified. Exactly one must be provided.".format(service_name))
|
||||
required.append(
|
||||
"Service '{}' has neither an image nor a build path "
|
||||
"specified. Exactly one must be provided.".format(service_name))
|
||||
else:
|
||||
required.append(_clean_error_message(error.message))
|
||||
elif error.validator == 'oneOf':
|
||||
|
@ -143,12 +152,25 @@ def process_errors(errors):
|
|||
|
||||
if len(error.path) > 0:
|
||||
config_key = " ".join(["'%s'" % k for k in error.path])
|
||||
type_errors.append("Service '{}' configuration key {} contains an invalid type, it should be {} {}".format(service_name, config_key, msg, error.validator_value))
|
||||
type_errors.append(
|
||||
"Service '{}' configuration key {} contains an invalid "
|
||||
"type, it should be {} {}".format(
|
||||
service_name,
|
||||
config_key,
|
||||
msg,
|
||||
error.validator_value))
|
||||
else:
|
||||
root_msgs.append("Service '{}' doesn\'t have any configuration options. All top level keys in your docker-compose.yml must map to a dictionary of configuration options.'".format(service_name))
|
||||
root_msgs.append(
|
||||
"Service '{}' doesn\'t have any configuration options. "
|
||||
"All top level keys in your docker-compose.yml must map "
|
||||
"to a dictionary of configuration options.'".format(service_name))
|
||||
elif error.validator == 'required':
|
||||
config_key = error.path[0]
|
||||
required.append("Service '{}' option '{}' is invalid, {}".format(service_name, config_key, _clean_error_message(error.message)))
|
||||
required.append(
|
||||
"Service '{}' option '{}' is invalid, {}".format(
|
||||
service_name,
|
||||
config_key,
|
||||
_clean_error_message(error.message)))
|
||||
elif error.validator == 'dependencies':
|
||||
dependency_key = list(error.validator_value.keys())[0]
|
||||
required_keys = ",".join(error.validator_value[dependency_key])
|
||||
|
|
|
@ -17,7 +17,8 @@ Compose found the following containers without labels:
|
|||
|
||||
{names_list}
|
||||
|
||||
As of Compose 1.3.0, containers are identified with labels instead of naming convention. If you want to continue using these containers, run:
|
||||
As of Compose 1.3.0, containers are identified with labels instead of naming
|
||||
convention. If you want to continue using these containers, run:
|
||||
|
||||
$ docker-compose migrate-to-labels
|
||||
|
||||
|
|
|
@ -157,7 +157,9 @@ class Project(object):
|
|||
try:
|
||||
links.append((self.get_service(service_name), link_name))
|
||||
except NoSuchService:
|
||||
raise ConfigurationError('Service "%s" has a link to service "%s" which does not exist.' % (service_dict['name'], service_name))
|
||||
raise ConfigurationError(
|
||||
'Service "%s" has a link to service "%s" which does not '
|
||||
'exist.' % (service_dict['name'], service_name))
|
||||
del service_dict['links']
|
||||
return links
|
||||
|
||||
|
@ -173,7 +175,11 @@ class Project(object):
|
|||
container = Container.from_id(self.client, volume_name)
|
||||
volumes_from.append(container)
|
||||
except APIError:
|
||||
raise ConfigurationError('Service "%s" mounts volumes from "%s", which is not the name of a service or container.' % (service_dict['name'], volume_name))
|
||||
raise ConfigurationError(
|
||||
'Service "%s" mounts volumes from "%s", which is '
|
||||
'not the name of a service or container.' % (
|
||||
service_dict['name'],
|
||||
volume_name))
|
||||
del service_dict['volumes_from']
|
||||
return volumes_from
|
||||
|
||||
|
@ -188,7 +194,11 @@ class Project(object):
|
|||
try:
|
||||
net = Container.from_id(self.client, net_name)
|
||||
except APIError:
|
||||
raise ConfigurationError('Service "%s" is trying to use the network of "%s", which is not the name of a service or container.' % (service_dict['name'], net_name))
|
||||
raise ConfigurationError(
|
||||
'Service "%s" is trying to use the network of "%s", '
|
||||
'which is not the name of a service or container.' % (
|
||||
service_dict['name'],
|
||||
net_name))
|
||||
else:
|
||||
net = service_dict['net']
|
||||
|
||||
|
|
|
@ -93,7 +93,9 @@ class CLITestCase(DockerClientTestCase):
|
|||
def test_pull_with_digest(self, mock_logging):
|
||||
self.command.dispatch(['-f', 'digest.yml', 'pull'], None)
|
||||
mock_logging.info.assert_any_call('Pulling simple (busybox:latest)...')
|
||||
mock_logging.info.assert_any_call('Pulling digest (busybox@sha256:38a203e1986cf79639cfb9b2e1d6e773de84002feea2d4eb006b52004ee8502d)...')
|
||||
mock_logging.info.assert_any_call(
|
||||
'Pulling digest (busybox@'
|
||||
'sha256:38a203e1986cf79639cfb9b2e1d6e773de84002feea2d4eb006b52004ee8502d)...')
|
||||
|
||||
@mock.patch('sys.stdout', new_callable=StringIO)
|
||||
def test_build_no_cache(self, mock_stdout):
|
||||
|
|
|
@ -804,7 +804,10 @@ class ServiceTest(DockerClientTestCase):
|
|||
self.assertEqual(env[k], v)
|
||||
|
||||
def test_env_from_file_combined_with_env(self):
|
||||
service = self.create_service('web', environment=['ONE=1', 'TWO=2', 'THREE=3'], env_file=['tests/fixtures/env/one.env', 'tests/fixtures/env/two.env'])
|
||||
service = self.create_service(
|
||||
'web',
|
||||
environment=['ONE=1', 'TWO=2', 'THREE=3'],
|
||||
env_file=['tests/fixtures/env/one.env', 'tests/fixtures/env/two.env'])
|
||||
env = create_and_start_container(service).environment
|
||||
for k, v in {'ONE': '1', 'TWO': '2', 'THREE': '3', 'FOO': 'baz', 'DOO': 'dah'}.items():
|
||||
self.assertEqual(env[k], v)
|
||||
|
|
|
@ -529,7 +529,10 @@ class MemoryOptionsTest(unittest.TestCase):
|
|||
When you set a 'memswap_limit' it is invalid config unless you also set
|
||||
a mem_limit
|
||||
"""
|
||||
expected_error_msg = "Invalid 'memswap_limit' configuration for 'foo' service: when defining 'memswap_limit' you must set 'mem_limit' as well"
|
||||
expected_error_msg = (
|
||||
"Invalid 'memswap_limit' configuration for 'foo' service: when "
|
||||
"defining 'memswap_limit' you must set 'mem_limit' as well"
|
||||
)
|
||||
with self.assertRaisesRegexp(ConfigurationError, expected_error_msg):
|
||||
config.load(
|
||||
config.ConfigDetails(
|
||||
|
|
|
@ -142,4 +142,12 @@ class GetContainerNameTestCase(unittest.TestCase):
|
|||
self.assertIsNone(get_container_name({}))
|
||||
self.assertEqual(get_container_name({'Name': 'myproject_db_1'}), 'myproject_db_1')
|
||||
self.assertEqual(get_container_name({'Names': ['/myproject_db_1', '/myproject_web_1/db']}), 'myproject_db_1')
|
||||
self.assertEqual(get_container_name({'Names': ['/swarm-host-1/myproject_db_1', '/swarm-host-1/myproject_web_1/db']}), 'myproject_db_1')
|
||||
self.assertEqual(
|
||||
get_container_name({
|
||||
'Names': [
|
||||
'/swarm-host-1/myproject_db_1',
|
||||
'/swarm-host-1/myproject_web_1/db'
|
||||
]
|
||||
}),
|
||||
'myproject_db_1'
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue