Remove name from config schema.
Refactors config validation of a service to use a ServiceConfig data object. Instead of passing around a bunch of related scalars, we can use the ServiceConfig object as a parameter to most of the service validation functions. This allows for a fix to the config schema, where the name is a field in the schema, but not actually in the configuration. My passing the name around as part of the ServiceConfig object, we don't need to add it to the config options. Fixes #2299 validate_against_service_schema() is moved from a conditional branch in ServiceExtendsResolver() to happen as one of the last steps after all configuration is merged. This schema only contains constraints which only need to be true at the very end of merging. Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
parent
5e97b806d5
commit
1f7faadc77
6 changed files with 62 additions and 67 deletions
|
|
@ -9,6 +9,7 @@ from .. import unittest
|
|||
from compose.cli.docker_client import docker_client
|
||||
from compose.config.config import process_service
|
||||
from compose.config.config import resolve_environment
|
||||
from compose.config.config import ServiceConfig
|
||||
from compose.const import LABEL_PROJECT
|
||||
from compose.progress_stream import stream_output
|
||||
from compose.service import Service
|
||||
|
|
@ -43,15 +44,13 @@ class DockerClientTestCase(unittest.TestCase):
|
|||
if 'command' not in kwargs:
|
||||
kwargs['command'] = ["top"]
|
||||
|
||||
# TODO: remove this once #2299 is fixed
|
||||
kwargs['name'] = name
|
||||
|
||||
options = process_service('.', kwargs)
|
||||
service_config = ServiceConfig('.', None, name, kwargs)
|
||||
options = process_service(service_config)
|
||||
options['environment'] = resolve_environment('.', kwargs)
|
||||
labels = options.setdefault('labels', {})
|
||||
labels['com.docker.compose.test-name'] = self.id()
|
||||
|
||||
return Service(client=self.client, project='composetest', **options)
|
||||
return Service(name, client=self.client, project='composetest', **options)
|
||||
|
||||
def check_build(self, *args, **kwargs):
|
||||
kwargs.setdefault('rm', True)
|
||||
|
|
|
|||
|
|
@ -20,12 +20,12 @@ def make_service_dict(name, service_dict, working_dir, filename=None):
|
|||
"""
|
||||
Test helper function to construct a ServiceExtendsResolver
|
||||
"""
|
||||
resolver = config.ServiceExtendsResolver(
|
||||
resolver = config.ServiceExtendsResolver(config.ServiceConfig(
|
||||
working_dir=working_dir,
|
||||
filename=filename,
|
||||
service_name=name,
|
||||
service_dict=service_dict)
|
||||
return config.process_service(working_dir, resolver.run())
|
||||
name=name,
|
||||
config=service_dict))
|
||||
return config.process_service(resolver.run())
|
||||
|
||||
|
||||
def service_sort(services):
|
||||
|
|
@ -651,7 +651,7 @@ class VolumeConfigTest(unittest.TestCase):
|
|||
|
||||
def test_volume_path_with_non_ascii_directory(self):
|
||||
volume = u'/Füü/data:/data'
|
||||
container_path = config.resolve_volume_path(".", volume, "test")
|
||||
container_path = config.resolve_volume_path(".", volume)
|
||||
self.assertEqual(container_path, volume)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue