mirror of https://github.com/docker/docker-py.git
Handle untyped ContainerSpec dict in _check_api_features
Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
d49c136d04
commit
b4802ea126
|
@ -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'
|
||||
|
|
|
@ -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']
|
||||
|
|
Loading…
Reference in New Issue