Skip to content

Commit 4303bc9

Browse files
authored
fix: CustomMake validator (#293)
* fix: Custom Make runtime validation * chore: Add doc * chore: black format
1 parent 713de19 commit 4303bc9

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

aws_lambda_builders/exceptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class UnsupportedRuntimeError(RuntimeValidatorError):
3737
Raise when runtime is not supported
3838
"""
3939

40-
MESSAGE = "Runtime {runtime} is not suppported"
40+
MESSAGE = "Runtime {runtime} is not supported"
4141

4242

4343
class UnsupportedArchitectureError(RuntimeValidatorError):
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"""
2+
Custom Make Runtime Validation
3+
"""
4+
5+
from aws_lambda_builders.validator import RuntimeValidator
6+
7+
8+
class CustomMakeRuntimeValidator(RuntimeValidator):
9+
"""
10+
Default runtime validator for CustomMake workflow
11+
"""
12+
13+
def __init__(self, runtime, architecture):
14+
super(CustomMakeRuntimeValidator, self).__init__(runtime, architecture)
15+
self._valid_runtime_path = None
16+
17+
def validate(self, runtime_path):
18+
self._runtime_path = runtime_path
19+
return runtime_path

aws_lambda_builders/workflows/custom_make/workflow.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
ProvidedMakeWorkflow
33
"""
4+
from aws_lambda_builders.workflows.custom_make.validator import CustomMakeRuntimeValidator
45
from aws_lambda_builders.workflow import BaseWorkflow, Capability
56
from aws_lambda_builders.actions import CopySourceAction
67
from aws_lambda_builders.path_resolver import PathResolver
@@ -56,3 +57,6 @@ def __init__(self, source_dir, artifacts_dir, scratch_dir, manifest_path, runtim
5657

5758
def get_resolvers(self):
5859
return [PathResolver(runtime="provided", binary="make", executable_search_paths=self.executable_search_paths)]
60+
61+
def get_validators(self):
62+
return [CustomMakeRuntimeValidator(runtime=self.runtime, architecture=self.architecture)]

tests/unit/test_workflow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ def test_must_raise_for_unknown_runtime(self):
316316
with self.assertRaises(WorkflowFailedError) as ex:
317317
self.work.run()
318318

319-
self.assertIn("Runtime runtime is not suppported", str(ex.exception))
319+
self.assertIn("Runtime runtime is not supported", str(ex.exception))
320320

321321
def test_must_raise_for_incompatible_runtime_and_architecture(self):
322322
self.work = self.MyWorkflow(

0 commit comments

Comments
 (0)