summaryrefslogtreecommitdiff
path: root/docker/api/image.py
diff options
context:
space:
mode:
authorJoffrey F <joffrey@docker.com>2018-01-08 18:11:29 -0800
committerJoffrey F <joffrey@docker.com>2018-01-23 16:59:09 -0800
commitf95b958429b38dab50929e013db3c636a12e1536 (patch)
treeb8de1cfd18d1c3c932592388143665f446e871f6 /docker/api/image.py
parentbf5e7702df3c835a5db4fc6b86500b4f4b659c14 (diff)
downloaddocker-py-1855-platform-option.tar.gz
Add support for experimental platform flag in build and pull1855-platform-option
Signed-off-by: Joffrey F <joffrey@docker.com>
Diffstat (limited to 'docker/api/image.py')
-rw-r--r--docker/api/image.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/docker/api/image.py b/docker/api/image.py
index 7755312..065fae3 100644
--- a/docker/api/image.py
+++ b/docker/api/image.py
@@ -323,7 +323,8 @@ class ImageApiMixin(object):
return self._result(self._post(url, params=params), True)
def pull(self, repository, tag=None, stream=False,
- insecure_registry=False, auth_config=None, decode=False):
+ insecure_registry=False, auth_config=None, decode=False,
+ platform=None):
"""
Pulls an image. Similar to the ``docker pull`` command.
@@ -336,6 +337,7 @@ class ImageApiMixin(object):
:py:meth:`~docker.api.daemon.DaemonApiMixin.login` has set for
this request. ``auth_config`` should contain the ``username``
and ``password`` keys to be valid.
+ platform (str): Platform in the format ``os[/arch[/variant]]``
Returns:
(generator or str): The output
@@ -376,7 +378,7 @@ class ImageApiMixin(object):
}
headers = {}
- if utils.compare_version('1.5', self._version) >= 0:
+ if utils.version_gte(self._version, '1.5'):
if auth_config is None:
header = auth.get_config_header(self, registry)
if header:
@@ -385,6 +387,13 @@ class ImageApiMixin(object):
log.debug('Sending supplied auth config')
headers['X-Registry-Auth'] = auth.encode_header(auth_config)
+ if platform is not None:
+ if utils.version_lt(self._version, '1.32'):
+ raise errors.InvalidVersion(
+ 'platform was only introduced in API version 1.32'
+ )
+ params['platform'] = platform
+
response = self._post(
self._url('/images/create'), params=params, headers=headers,
stream=stream, timeout=None