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:
Daniel Nephin 2015-11-06 11:57:27 -05:00
commit 7fc577c31d
6 changed files with 62 additions and 67 deletions

View file

@ -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)