mirror of
https://github.com/docker/compose.git
synced 2025-07-24 22:24:41 +02:00
address PR feedback
Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
This commit is contained in:
parent
5b55a08846
commit
467c731869
@ -37,7 +37,10 @@ def sort_service_dicts(services):
|
|||||||
return [link.split(':')[0] for link in links]
|
return [link.split(':')[0] for link in links]
|
||||||
|
|
||||||
def get_service_names_from_volumes_from(volumes_from):
|
def get_service_names_from_volumes_from(volumes_from):
|
||||||
return [volume_from.split(':')[0] for volume_from in volumes_from]
|
return [
|
||||||
|
parse_volume_from_spec(volume_from).source
|
||||||
|
for volume_from in volumes_from
|
||||||
|
]
|
||||||
|
|
||||||
def get_service_dependents(service_dict, services):
|
def get_service_dependents(service_dict, services):
|
||||||
name = service_dict['name']
|
name = service_dict['name']
|
||||||
@ -195,7 +198,7 @@ class Project(object):
|
|||||||
raise ConfigurationError(
|
raise ConfigurationError(
|
||||||
'Service "%s" mounts volumes from "%s", which is '
|
'Service "%s" mounts volumes from "%s", which is '
|
||||||
'not the name of a service or container.' % (
|
'not the name of a service or container.' % (
|
||||||
volume_from_config,
|
service_dict['name'],
|
||||||
volume_from_spec.source))
|
volume_from_spec.source))
|
||||||
volumes_from.append(volume_from_spec)
|
volumes_from.append(volume_from_spec)
|
||||||
del service_dict['volumes_from']
|
del service_dict['volumes_from']
|
||||||
|
@ -6,6 +6,7 @@ import os
|
|||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
from operator import attrgetter
|
||||||
|
|
||||||
import enum
|
import enum
|
||||||
import six
|
import six
|
||||||
@ -1009,10 +1010,6 @@ def parse_volume_from_spec(volume_from_config):
|
|||||||
else:
|
else:
|
||||||
source, mode = parts
|
source, mode = parts
|
||||||
|
|
||||||
if mode not in ('rw', 'ro'):
|
|
||||||
raise ConfigError("VolumeFrom %s has invalid mode (%s), should be "
|
|
||||||
"one of: rw, ro." % (volume_from_config, mode))
|
|
||||||
|
|
||||||
return VolumeFromSpec(source, mode)
|
return VolumeFromSpec(source, mode)
|
||||||
|
|
||||||
|
|
||||||
|
@ -273,7 +273,13 @@ class ServiceTest(DockerClientTestCase):
|
|||||||
command=["top"],
|
command=["top"],
|
||||||
labels={LABEL_PROJECT: 'composetest'},
|
labels={LABEL_PROJECT: 'composetest'},
|
||||||
)
|
)
|
||||||
host_service = self.create_service('host', volumes_from=[VolumeFromSpec(volume_service, 'rw'), VolumeFromSpec(volume_container_2, 'rw')])
|
host_service = self.create_service(
|
||||||
|
'host',
|
||||||
|
volumes_from=[
|
||||||
|
VolumeFromSpec(volume_service, 'rw'),
|
||||||
|
VolumeFromSpec(volume_container_2, 'rw')
|
||||||
|
]
|
||||||
|
)
|
||||||
host_container = host_service.create_container()
|
host_container = host_service.create_container()
|
||||||
host_service.start_container(host_container)
|
host_service.start_container(host_container)
|
||||||
self.assertIn(volume_container_1.id + ':rw',
|
self.assertIn(volume_container_1.id + ':rw',
|
||||||
|
@ -379,7 +379,7 @@ class ServiceTest(unittest.TestCase):
|
|||||||
client=self.mock_client,
|
client=self.mock_client,
|
||||||
net=ServiceNet(Service('other')),
|
net=ServiceNet(Service('other')),
|
||||||
links=[(Service('one'), 'one')],
|
links=[(Service('one'), 'one')],
|
||||||
volumes_from=[Service('two')])
|
volumes_from=[VolumeFromSpec(Service('two'), 'rw')])
|
||||||
|
|
||||||
config_dict = service.config_dict()
|
config_dict = service.config_dict()
|
||||||
expected = {
|
expected = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user