Rename ServiceLoader to ServiceExtendsResolver

ServiceLoader has evolved to be not really all that related to "loading" a
service. It's responsibility is more to do with handling the `extends`
field, which is only part of loading.  The class and its primary method
(make_service_dict()) were renamed to better reflect their responsibility.

As part of that change process_container_options() was removed from
make_service_dict() and renamed to process_service().  It contains logic for
handling the non-extends options.

This change allows us to remove the hacks from testcase.py and only call
the functions we need to format a service dict correctly for integration tests.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
Daniel Nephin 2015-11-06 17:18:47 -05:00
commit 87d79d4d99
4 changed files with 45 additions and 35 deletions

View file

@ -7,7 +7,8 @@ from pytest import skip
from .. import unittest
from compose.cli.docker_client import docker_client
from compose.config.config import ServiceLoader
from compose.config.config import process_service
from compose.config.config import resolve_environment
from compose.const import LABEL_PROJECT
from compose.progress_stream import stream_output
from compose.service import Service
@ -42,23 +43,15 @@ class DockerClientTestCase(unittest.TestCase):
if 'command' not in kwargs:
kwargs['command'] = ["top"]
workaround_options = {}
for option in ['links', 'volumes_from', 'net']:
if option in kwargs:
workaround_options[option] = kwargs.pop(option, None)
options = ServiceLoader(
working_dir='.',
filename=None,
service_name=name,
service_dict=kwargs
).make_service_dict()
options.update(workaround_options)
# TODO: remove this once #2299 is fixed
kwargs['name'] = name
options = process_service('.', kwargs)
options['environment'] = resolve_environment('.', kwargs)
labels = options.setdefault('labels', {})
labels['com.docker.compose.test-name'] = self.id()
return Service(project='composetest', client=self.client, **options)
return Service(client=self.client, project='composetest', **options)
def check_build(self, *args, **kwargs):
kwargs.setdefault('rm', True)