Skip to content

Commit 35c4cbd

Browse files
committed
Bumped default API version, fixed rename()
1 parent 41a9417 commit 35c4cbd

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

docker/client.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
if not six.PY3:
3434
import websocket
3535

36-
DEFAULT_DOCKER_API_VERSION = '1.16'
36+
DEFAULT_DOCKER_API_VERSION = '1.17'
3737
DEFAULT_TIMEOUT_SECONDS = 60
3838
STREAM_HEADER_SIZE_BYTES = 8
3939

@@ -374,8 +374,12 @@ def stream_result():
374374

375375
sep = bytes() if six.PY3 else str()
376376

377-
return stream and self._multiplexed_response_stream_helper(response) or \
378-
sep.join([x for x in self._multiplexed_buffer_helper(response)])
377+
if stream:
378+
return self._multiplexed_response_stream_helper(response)
379+
else:
380+
return sep.join(
381+
[x for x in self._multiplexed_buffer_helper(response)]
382+
)
379383

380384
def attach_socket(self, container, params=None, ws=False):
381385
if params is None:
@@ -893,11 +897,15 @@ def remove_image(self, image, force=False, noprune=False):
893897
self._raise_for_status(res)
894898

895899
def rename(self, container, name):
900+
if utils.compare_version('1.17', self._version) < 0:
901+
raise errors.InvalidVersion(
902+
'rename was only introduced in API version 1.17'
903+
)
896904
if isinstance(container, dict):
897905
container = container.get('Id')
898906
url = self._url("/containers/{0}/rename".format(container))
899907
params = {'name': name}
900-
res = self._post(url, None, params=params)
908+
res = self._post(url, params=params)
901909
self._raise_for_status(res)
902910

903911
def resize(self, container, height, width):

0 commit comments

Comments
 (0)