From 4259a52c51a8b22894bcc437f0b0da3571f0d61f Mon Sep 17 00:00:00 2001 From: Stefan Smith Date: Fri, 18 Jan 2019 21:45:49 +0000 Subject: [PATCH] feat(layers): remove compression of docker context (#862) --- samcli/lib/utils/tar.py | 2 +- samcli/local/docker/lambda_image.py | 1 - tests/unit/lib/utils/test_tar.py | 2 +- tests/unit/local/docker/test_lambda_image.py | 9 +++------ 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/samcli/lib/utils/tar.py b/samcli/lib/utils/tar.py index b732faee47..38417d6e75 100644 --- a/samcli/lib/utils/tar.py +++ b/samcli/lib/utils/tar.py @@ -23,7 +23,7 @@ def create_tarball(tar_paths): """ tarballfile = TemporaryFile() - with tarfile.open(fileobj=tarballfile, mode='w:gz') as archive: + with tarfile.open(fileobj=tarballfile, mode='w') as archive: for path_on_system, path_in_tarball in tar_paths.items(): archive.add(path_on_system, arcname=path_in_tarball) diff --git a/samcli/local/docker/lambda_image.py b/samcli/local/docker/lambda_image.py index fdcb02f0ac..05c70980a1 100644 --- a/samcli/local/docker/lambda_image.py +++ b/samcli/local/docker/lambda_image.py @@ -182,7 +182,6 @@ def _build_image(self, base_image, docker_tag, layers): self.docker_client.images.build(fileobj=tarballfile, custom_context=True, rm=True, - encoding='gzip', tag=docker_tag, pull=not self.skip_pull_image) except (docker.errors.BuildError, docker.errors.APIError): diff --git a/tests/unit/lib/utils/test_tar.py b/tests/unit/lib/utils/test_tar.py index ffc613af56..d429c8cc37 100644 --- a/tests/unit/lib/utils/test_tar.py +++ b/tests/unit/lib/utils/test_tar.py @@ -25,4 +25,4 @@ def test_generating_tarball(self, temporary_file_patch, tarfile_open_patch): temp_file_mock.flush.assert_called_once() temp_file_mock.seek.assert_called_once_with(0) temp_file_mock.close.assert_called_once() - tarfile_open_patch.assert_called_once_with(fileobj=temp_file_mock, mode='w:gz') + tarfile_open_patch.assert_called_once_with(fileobj=temp_file_mock, mode='w') diff --git a/tests/unit/local/docker/test_lambda_image.py b/tests/unit/local/docker/test_lambda_image.py index 7a50aef1ee..86934ab524 100644 --- a/tests/unit/local/docker/test_lambda_image.py +++ b/tests/unit/local/docker/test_lambda_image.py @@ -171,8 +171,7 @@ def test_build_image(self, generate_dockerfile_patch, path_patch, uuid_patch, cr rm=True, tag="docker_tag", pull=False, - custom_context=True, - encoding='gzip') + custom_context=True) docker_full_path_mock.unlink.assert_called_once() @@ -218,8 +217,7 @@ def test_build_image_fails_with_BuildError(self, rm=True, tag="docker_tag", pull=False, - custom_context=True, - encoding='gzip') + custom_context=True) docker_full_path_mock.unlink.assert_not_called() @@ -264,6 +262,5 @@ def test_build_image_fails_with_ApiError(self, rm=True, tag="docker_tag", pull=False, - custom_context=True, - encoding='gzip') + custom_context=True) docker_full_path_mock.unlink.assert_called_once()