Kaydet (Commit) c6030027 authored tarafından Joffrey F's avatar Joffrey F

Modernize exec_api.py

Signed-off-by: 's avatarJoffrey F <joffrey@docker.com>
üst 13dfb138
...@@ -35,18 +35,19 @@ class ExecApiMixin(object): ...@@ -35,18 +35,19 @@ class ExecApiMixin(object):
If the server returns an error. If the server returns an error.
""" """
if privileged and utils.compare_version('1.19', self._version) < 0: if privileged and utils.version_lt(self._version, '1.19'):
raise errors.InvalidVersion( raise errors.InvalidVersion(
'Privileged exec is not supported in API < 1.19' 'Privileged exec is not supported in API < 1.19'
) )
if user and utils.compare_version('1.19', self._version) < 0: if user and utils.version_lt(self._version, '1.19'):
raise errors.InvalidVersion( raise errors.InvalidVersion(
'User-specific exec is not supported in API < 1.19' 'User-specific exec is not supported in API < 1.19'
) )
if environment and utils.compare_version('1.25', self._version) < 0: if environment is not None and utils.version_lt(self._version, '1.25'):
raise errors.InvalidVersion( raise errors.InvalidVersion(
'Setting environment for exec is not supported in API < 1.25' 'Setting environment for exec is not supported in API < 1.25'
) )
if isinstance(cmd, six.string_types): if isinstance(cmd, six.string_types):
cmd = utils.split_command(cmd) cmd = utils.split_command(cmd)
...@@ -109,6 +110,7 @@ class ExecApiMixin(object): ...@@ -109,6 +110,7 @@ class ExecApiMixin(object):
self._raise_for_status(res) self._raise_for_status(res)
@utils.minimum_version('1.15') @utils.minimum_version('1.15')
@utils.check_resource
def exec_start(self, exec_id, detach=False, tty=False, stream=False, def exec_start(self, exec_id, detach=False, tty=False, stream=False,
socket=False): socket=False):
""" """
...@@ -130,8 +132,6 @@ class ExecApiMixin(object): ...@@ -130,8 +132,6 @@ class ExecApiMixin(object):
If the server returns an error. If the server returns an error.
""" """
# we want opened socket if socket == True # we want opened socket if socket == True
if isinstance(exec_id, dict):
exec_id = exec_id.get('Id')
data = { data = {
'Tty': tty, 'Tty': tty,
......
...@@ -132,7 +132,7 @@ class ExecTest(BaseAPIIntegrationTest): ...@@ -132,7 +132,7 @@ class ExecTest(BaseAPIIntegrationTest):
self.tmp_containers.append(id) self.tmp_containers.append(id)
res = self.client.exec_create(id, 'env', environment=["X=Y"]) res = self.client.exec_create(id, 'env', environment=["X=Y"])
self.assertIn('Id', res) assert 'Id' in res
exec_log = self.client.exec_start(res) exec_log = self.client.exec_start(res)
self.assertIn(b'X=Y\n', exec_log) assert b'X=Y\n' in exec_log
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment