-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: Error on --use-container for dotnet builds #1096
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
bd98c09
ce2efae
022a9eb
a117338
376ae11
50907bb
7b82db8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -125,6 +125,41 @@ def get_workflow_config(runtime, code_dir, project_dir): | |
| .format(runtime, str(ex))) | ||
|
|
||
|
|
||
| def supports_build_in_container(config): | ||
| """ | ||
| Given a workflow config, this method provides a boolean on whether the workflow can run within a container or not. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| config namedtuple(Capability) | ||
| Config specifying the particular build workflow | ||
|
|
||
| Returns | ||
| ------- | ||
| tuple(bool, str) | ||
| True, if this workflow can be built inside a container. False, along with a reason message if it cannot be. | ||
| """ | ||
|
|
||
| def _key(c): | ||
| return str(c.language) + str(c.dependency_manager) + str(c.application_framework) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn’t this be the hash function on the object? It’s much cleaner that way.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The whole point of namedtuple is so you automatically get a sane hash function. I don't want to break that abstraction by defining a custom has that takes only a handful of properties. May be I am wrong here, so let me know if a custom hash is right way of doing things.. |
||
|
|
||
| # This information could have beeen bundled inside the Workflow Config object. But we this way because | ||
| # ultimately the workflow's implementation dictates whether it can run within a container or not. | ||
| # A "workflow config" is like a primary key to identify the workflow. So we use the config as a key in the | ||
| # map to identify which workflows can support building within a container. | ||
|
|
||
| unsupported = { | ||
| _key(DOTNET_CLIPACKAGE_CONFIG): "We do not support building .NET Core Lambda functions within a container. " | ||
| "Try building without the container. Most .NET Core functions will build " | ||
| "successfully.", | ||
| } | ||
|
|
||
| if _key(config) in unsupported: | ||
| return False, unsupported[config] | ||
|
|
||
| return True, None | ||
|
|
||
|
|
||
| class BasicWorkflowSelector(object): | ||
| """ | ||
| Basic workflow selector that returns the first available configuration in the given list of configurations | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,7 @@ | |
|
|
||
| from samcli.lib.build.app_builder import ApplicationBuilder,\ | ||
| UnsupportedBuilderLibraryVersionError, BuildError, \ | ||
| LambdaBuilderError | ||
| LambdaBuilderError, ContainerBuildNotSupported | ||
|
|
||
|
|
||
| class TestApplicationBuilder_build(TestCase): | ||
|
|
@@ -325,6 +325,23 @@ def test_must_raise_on_docker_not_running(self): | |
| self.assertEquals(str(ctx.exception), | ||
| "Docker is unreachable. Docker needs to be running to build inside a container.") | ||
|
|
||
| @patch("samcli.lib.build.app_builder.supports_build_in_container") | ||
| def test_must_raise_on_unsupported_container_build(self, supports_build_in_container_mock): | ||
| config = Mock() | ||
|
|
||
| reason = "my reason" | ||
| supports_build_in_container_mock.return_value = (False, reason) | ||
|
|
||
| with self.assertRaises(ContainerBuildNotSupported) as ctx: | ||
| self.builder._build_function_on_container(config, | ||
| "source_dir", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we need to pass in mode? we may need changes in
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, that's happening as part of the other PR that Jacob created |
||
| "artifacts_dir", | ||
| "scratch_dir", | ||
| "manifest_path", | ||
| "runtime") | ||
|
|
||
| self.assertEquals(str(ctx.exception), reason) | ||
|
|
||
|
|
||
| class TestApplicationBuilder_parse_builder_response(TestCase): | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.