diff options
author | Joffrey F <joffrey@docker.com> | 2018-01-31 14:32:32 -0800 |
---|---|---|
committer | Joffrey F <joffrey@docker.com> | 2018-01-31 14:42:01 -0800 |
commit | df8422d0791d7d03cd3e1efe37a9c72f242f1f78 (patch) | |
tree | db555dc7a8c4f16f33c6ac4a7ddd1c072dbe6eef /docker/api/build.py | |
parent | b180b8770a265e33099bd6da76c3e556a1028491 (diff) | |
download | docker-py-cleanup_deprecated.tar.gz |
Refuse API version < 1.21 ; Remove associated code pathscleanup_deprecated
Signed-off-by: Joffrey F <joffrey@docker.com>
Diffstat (limited to 'docker/api/build.py')
-rw-r--r-- | docker/api/build.py | 50 |
1 files changed, 8 insertions, 42 deletions
diff --git a/docker/api/build.py b/docker/api/build.py index 220c93f..56f1fcf 100644 --- a/docker/api/build.py +++ b/docker/api/build.py @@ -1,7 +1,6 @@ import json import logging import os -import re from .. import auth from .. import constants @@ -14,7 +13,7 @@ log = logging.getLogger(__name__) class BuildApiMixin(object): def build(self, path=None, tag=None, quiet=False, fileobj=None, - nocache=False, rm=False, stream=False, timeout=None, + nocache=False, rm=False, timeout=None, custom_context=False, encoding=None, pull=False, forcerm=False, dockerfile=None, container_limits=None, decode=False, buildargs=None, gzip=False, shmsize=None, @@ -67,9 +66,6 @@ class BuildApiMixin(object): rm (bool): Remove intermediate containers. The ``docker build`` command now defaults to ``--rm=true``, but we have kept the old default of `False` to preserve backward compatibility - stream (bool): *Deprecated for API version > 1.8 (always True)*. - Return a blocking generator you can iterate over to retrieve - build output as it happens timeout (int): HTTP timeout custom_context (bool): Optional if using ``fileobj`` encoding (str): The encoding for a stream. Set to ``gzip`` for @@ -154,17 +150,6 @@ class BuildApiMixin(object): ) encoding = 'gzip' if gzip else encoding - if utils.compare_version('1.8', self._version) >= 0: - stream = True - - if dockerfile and utils.compare_version('1.17', self._version) < 0: - raise errors.InvalidVersion( - 'dockerfile was only introduced in API version 1.17' - ) - - if utils.compare_version('1.19', self._version) < 0: - pull = 1 if pull else 0 - u = self._url('/build') params = { 't': tag, @@ -179,12 +164,7 @@ class BuildApiMixin(object): params.update(container_limits) if buildargs: - if utils.version_gte(self._version, '1.21'): - params.update({'buildargs': json.dumps(buildargs)}) - else: - raise errors.InvalidVersion( - 'buildargs was only introduced in API version 1.21' - ) + params.update({'buildargs': json.dumps(buildargs)}) if shmsize: if utils.version_gte(self._version, '1.22'): @@ -256,30 +236,21 @@ class BuildApiMixin(object): if encoding: headers['Content-Encoding'] = encoding - if utils.compare_version('1.9', self._version) >= 0: - self._set_auth_headers(headers) + self._set_auth_headers(headers) response = self._post( u, data=context, params=params, headers=headers, - stream=stream, + stream=True, timeout=timeout, ) if context is not None and not custom_context: context.close() - if stream: - return self._stream_helper(response, decode=decode) - else: - output = self._result(response) - srch = r'Successfully built ([0-9a-f]+)' - match = re.search(srch, output) - if not match: - return None, output - return match.group(1), output + return self._stream_helper(response, decode=decode) def _set_auth_headers(self, headers): log.debug('Looking for auth config') @@ -316,13 +287,8 @@ class BuildApiMixin(object): ) ) - if utils.compare_version('1.19', self._version) >= 0: - headers['X-Registry-Config'] = auth.encode_header( - auth_data - ) - else: - headers['X-Registry-Config'] = auth.encode_header({ - 'configs': auth_data - }) + headers['X-Registry-Config'] = auth.encode_header( + auth_data + ) else: log.debug('No auth config found') |