Pick the first container

Rather than inefficiently looping through all the containers that a
service has and overriding each volumes_from value, pick the first
one and return that.

Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
This commit is contained in:
Mazz Mosley 2015-10-06 13:11:49 +01:00
commit f9028703f4
3 changed files with 6 additions and 5 deletions

View file

@ -994,8 +994,9 @@ def build_volume_from(volume_from_spec):
containers = volume_from_spec.source.containers(stopped=True)
if not containers:
return ["{}:{}".format(volume_from_spec.source.create_container().id, volume_from_spec.mode)]
else:
return ["{}:{}".format(container.id, volume_from_spec.mode) for container in containers]
container = containers[0]
return ["{}:{}".format(container.id, volume_from_spec.mode)]
elif isinstance(volume_from_spec.source, Container):
return ["{}:{}".format(volume_from_spec.source.id, volume_from_spec.mode)]