mirror of https://github.com/docker/compose.git
Support legacy logging options format
Additional test for legacy compose file. Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
21aae13e77
commit
46585fb8e1
|
@ -504,6 +504,16 @@ def finalize_service(service_config):
|
|||
if 'restart' in service_dict:
|
||||
service_dict['restart'] = parse_restart_spec(service_dict['restart'])
|
||||
|
||||
if 'log_driver' in service_dict or 'log_opt' in service_dict:
|
||||
if 'logging' not in service_dict:
|
||||
service_dict['logging'] = {}
|
||||
if 'log_driver' in service_dict:
|
||||
service_dict['logging']['driver'] = service_dict['log_driver']
|
||||
del service_dict['log_driver']
|
||||
if 'log_opt' in service_dict:
|
||||
service_dict['logging']['options'] = service_dict['log_opt']
|
||||
del service_dict['log_opt']
|
||||
|
||||
return service_dict
|
||||
|
||||
|
||||
|
|
|
@ -730,6 +730,20 @@ class CLITestCase(DockerClientTestCase):
|
|||
self.assertEqual(log_config.get('Type'), 'json-file')
|
||||
self.assertEqual(log_config.get('Config')['max-size'], '10m')
|
||||
|
||||
def test_up_logging_legacy(self):
|
||||
self.base_dir = 'tests/fixtures/logging-composefile-legacy'
|
||||
self.dispatch(['up', '-d'])
|
||||
simple = self.project.get_service('simple').containers()[0]
|
||||
log_config = simple.get('HostConfig.LogConfig')
|
||||
self.assertTrue(log_config)
|
||||
self.assertEqual(log_config.get('Type'), 'none')
|
||||
|
||||
another = self.project.get_service('another').containers()[0]
|
||||
log_config = another.get('HostConfig.LogConfig')
|
||||
self.assertTrue(log_config)
|
||||
self.assertEqual(log_config.get('Type'), 'json-file')
|
||||
self.assertEqual(log_config.get('Config')['max-size'], '10m')
|
||||
|
||||
def test_up_logging_with_multiple_files(self):
|
||||
self.base_dir = 'tests/fixtures/logging-composefile'
|
||||
config_paths = [
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
simple:
|
||||
image: busybox:latest
|
||||
command: top
|
||||
log_driver: "none"
|
||||
another:
|
||||
image: busybox:latest
|
||||
command: top
|
||||
log_driver: "json-file"
|
||||
log_opt:
|
||||
max-size: "10m"
|
Loading…
Reference in New Issue