summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoffrey F <joffrey@docker.com>2016-03-22 18:09:33 -0700
committerJoffrey F <joffrey@docker.com>2016-03-22 18:14:16 -0700
commita67f4c1ecce1024d158c687e304f623017341b58 (patch)
treea0a175a41adb28f73117ce9241178b16a61a83c7
parent9dbccce5b68dca9e7139f4cac474bcadc4f06bb1 (diff)
downloaddocker-py-a67f4c1ecce1024d158c687e304f623017341b58.tar.gz
Make gzip encoding optional
Signed-off-by: Joffrey F <joffrey@docker.com>
-rw-r--r--docker/api/build.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/docker/api/build.py b/docker/api/build.py
index a593da7..971a50e 100644
--- a/docker/api/build.py
+++ b/docker/api/build.py
@@ -17,11 +17,15 @@ class BuildApiMixin(object):
nocache=False, rm=False, stream=False, timeout=None,
custom_context=False, encoding=None, pull=False,
forcerm=False, dockerfile=None, container_limits=None,
- decode=False, buildargs=None):
+ decode=False, buildargs=None, gzip=False):
remote = context = headers = None
container_limits = container_limits or {}
if path is None and fileobj is None:
raise TypeError("Either path or fileobj needs to be provided.")
+ if gzip and encoding is not None:
+ raise errors.DockerException(
+ 'Can not use custom encoding if gzip is enabled'
+ )
for key in container_limits.keys():
if key not in constants.CONTAINER_LIMITS_KEYS:
@@ -46,9 +50,10 @@ class BuildApiMixin(object):
if os.path.exists(dockerignore):
with open(dockerignore, 'r') as f:
exclude = list(filter(bool, f.read().splitlines()))
- context = utils.tar(path, exclude=exclude, dockerfile=dockerfile,
- gzip=True)
- encoding = 'gizp'
+ context = utils.tar(
+ path, exclude=exclude, dockerfile=dockerfile, gzip=gzip
+ )
+ encoding = 'gzip' if gzip else encoding
if utils.compare_version('1.8', self._version) >= 0:
stream = True