From ee6c4b1b9961dd8396c668d6ec656d739809aa9d Mon Sep 17 00:00:00 2001 From: Jacob Fuss Date: Thu, 1 Aug 2019 08:06:46 -0700 Subject: [PATCH 1/2] Fetch amazon/lambda-build-nodejs10.x build image --- samcli/local/docker/lambda_build_container.py | 6 ++++-- tests/unit/local/docker/test_lambda_build_container.py | 10 +++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/samcli/local/docker/lambda_build_container.py b/samcli/local/docker/lambda_build_container.py index b1e3d23077..60a865e3ec 100644 --- a/samcli/local/docker/lambda_build_container.py +++ b/samcli/local/docker/lambda_build_container.py @@ -22,7 +22,7 @@ class LambdaBuildContainer(Container): and if the build was successful, copies back artifacts to the host filesystem """ - _IMAGE_REPO_NAME = "lambci/lambda" + _LAMBCI_IMAGE_REPO_NAME = "lambci/lambda" _BUILDERS_EXECUTABLE = "lambda-builders" def __init__(self, # pylint: disable=too-many-locals @@ -229,4 +229,6 @@ def _convert_to_container_dirs(host_paths_to_convert, host_to_container_path_map @staticmethod def _get_image(runtime): - return "{}:build-{}".format(LambdaBuildContainer._IMAGE_REPO_NAME, runtime) + runtime_to_images = {"nodejs10.x": "amazon/lambda-build-node10.x"} + + return runtime_to_images.get(runtime, "{}:build-{}".format(LambdaBuildContainer._LAMBCI_IMAGE_REPO_NAME, runtime)) diff --git a/tests/unit/local/docker/test_lambda_build_container.py b/tests/unit/local/docker/test_lambda_build_container.py index edda1db09f..c558086998 100644 --- a/tests/unit/local/docker/test_lambda_build_container.py +++ b/tests/unit/local/docker/test_lambda_build_container.py @@ -8,10 +8,11 @@ except ImportError: import pathlib2 as pathlib - from unittest import TestCase from mock import patch +from parameterized import parameterized + from samcli.local.docker.lambda_build_container import LambdaBuildContainer @@ -157,8 +158,11 @@ def test_must_override_manifest_if_equal_to_source(self): class TestLambdaBuildContainer_get_image(TestCase): - def test_must_get_image_name(self): - self.assertEquals("lambci/lambda:build-myruntime", LambdaBuildContainer._get_image("myruntime")) + @parameterized.expand([("myruntime", "lambci/lambda:build-myruntime"), + ("nodejs10.x", "amazon/lambda-build-node10.x") + ]) + def test_must_get_image_name(self, runtime, expected_image_name): + self.assertEquals(expected_image_name, LambdaBuildContainer._get_image(runtime)) class TestLambdaBuildContainer_get_entrypoint(TestCase): From 2e643eb13136445e598e23f9c0d573b2a5a5e82d Mon Sep 17 00:00:00 2001 From: Jacob Fuss Date: Tue, 13 Aug 2019 20:32:42 -0700 Subject: [PATCH 2/2] Fix flake8 errors --- samcli/local/docker/lambda_build_container.py | 3 ++- tests/unit/local/docker/test_lambda_build_container.py | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/samcli/local/docker/lambda_build_container.py b/samcli/local/docker/lambda_build_container.py index 60a865e3ec..8952328182 100644 --- a/samcli/local/docker/lambda_build_container.py +++ b/samcli/local/docker/lambda_build_container.py @@ -231,4 +231,5 @@ def _convert_to_container_dirs(host_paths_to_convert, host_to_container_path_map def _get_image(runtime): runtime_to_images = {"nodejs10.x": "amazon/lambda-build-node10.x"} - return runtime_to_images.get(runtime, "{}:build-{}".format(LambdaBuildContainer._LAMBCI_IMAGE_REPO_NAME, runtime)) + return runtime_to_images.get(runtime, + "{}:build-{}".format(LambdaBuildContainer._LAMBCI_IMAGE_REPO_NAME, runtime)) diff --git a/tests/unit/local/docker/test_lambda_build_container.py b/tests/unit/local/docker/test_lambda_build_container.py index c558086998..f51e8589be 100644 --- a/tests/unit/local/docker/test_lambda_build_container.py +++ b/tests/unit/local/docker/test_lambda_build_container.py @@ -158,9 +158,10 @@ def test_must_override_manifest_if_equal_to_source(self): class TestLambdaBuildContainer_get_image(TestCase): - @parameterized.expand([("myruntime", "lambci/lambda:build-myruntime"), - ("nodejs10.x", "amazon/lambda-build-node10.x") - ]) + @parameterized.expand([ + ("myruntime", "lambci/lambda:build-myruntime"), + ("nodejs10.x", "amazon/lambda-build-node10.x") + ]) def test_must_get_image_name(self, runtime, expected_image_name): self.assertEquals(expected_image_name, LambdaBuildContainer._get_image(runtime))