diff options
author | Joffrey F <joffrey@docker.com> | 2017-08-15 16:07:47 -0700 |
---|---|---|
committer | Joffrey F <f.joffrey@gmail.com> | 2017-08-17 13:38:40 -0700 |
commit | b4802ea12626bb9d987c34f679ac04d97a402f9f (patch) | |
tree | 79407ae0bcc178cb8fe258d2a9d18b7503485974 | |
parent | d49c136d042db105a20053ed933776534ff8f5b3 (diff) | |
download | docker-py-b4802ea12626bb9d987c34f679ac04d97a402f9f.tar.gz |
Handle untyped ContainerSpec dict in _check_api_features
Signed-off-by: Joffrey F <joffrey@docker.com>
-rw-r--r-- | docker/api/service.py | 2 | ||||
-rw-r--r-- | tests/integration/api_service_test.py | 17 |
2 files changed, 18 insertions, 1 deletions
diff --git a/docker/api/service.py b/docker/api/service.py index cc16cc3..4b555a5 100644 --- a/docker/api/service.py +++ b/docker/api/service.py @@ -38,7 +38,7 @@ def _check_api_features(version, task_template, update_config): 'Placement.preferences is not supported in' ' API version < 1.27' ) - if task_template.container_spec.get('TTY'): + if task_template.get('ContainerSpec', {}).get('TTY'): if utils.version_lt(version, '1.25'): raise errors.InvalidVersion( 'ContainerSpec.TTY is not supported in API version < 1.25' diff --git a/tests/integration/api_service_test.py b/tests/integration/api_service_test.py index 54111a7..c966916 100644 --- a/tests/integration/api_service_test.py +++ b/tests/integration/api_service_test.py @@ -376,6 +376,23 @@ class ServiceTest(BaseAPIIntegrationTest): assert 'TTY' in con_spec assert con_spec['TTY'] is True + @requires_api_version('1.25') + def test_create_service_with_tty_dict(self): + container_spec = { + 'Image': BUSYBOX, + 'Command': ['true'], + 'TTY': True + } + task_tmpl = docker.types.TaskTemplate(container_spec) + name = self.get_service_name() + svc_id = self.client.create_service(task_tmpl, name=name) + svc_info = self.client.inspect_service(svc_id) + assert 'TaskTemplate' in svc_info['Spec'] + assert 'ContainerSpec' in svc_info['Spec']['TaskTemplate'] + con_spec = svc_info['Spec']['TaskTemplate']['ContainerSpec'] + assert 'TTY' in con_spec + assert con_spec['TTY'] is True + def test_create_service_global_mode(self): container_spec = docker.types.ContainerSpec( BUSYBOX, ['echo', 'hello'] |