Skip to content

Commit 33ef7b9

Browse files
authored
Remove runtime checks and leave it to the plugin (#909)
1 parent 8152d01 commit 33ef7b9

File tree

2 files changed

+18
-32
lines changed

2 files changed

+18
-32
lines changed

src/rpdk/core/project.py

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -67,27 +67,13 @@
6767

6868
CFN_METADATA_FILENAME = ".cfn_metadata.json"
6969

70-
LAMBDA_RUNTIMES = {
71-
"noexec", # cannot be executed, schema only
72-
"java8",
73-
"java11",
74-
"go1.x",
75-
"python3.6",
76-
"python3.7",
77-
"python3.8",
78-
"dotnetcore2.1",
79-
"nodejs10.x",
80-
"nodejs12.x",
81-
"nodejs14.x",
82-
}
83-
8470
SETTINGS_VALIDATOR = Draft7Validator(
8571
{
8672
"properties": {
8773
"artifact_type": {"type": "string"},
8874
"language": {"type": "string"},
8975
"typeName": {"type": "string", "pattern": TYPE_NAME_RESOURCE_REGEX},
90-
"runtime": {"type": "string", "enum": list(LAMBDA_RUNTIMES)},
76+
"runtime": {"type": "string"},
9177
"entrypoint": {"type": ["string", "null"]},
9278
"testEntrypoint": {"type": ["string", "null"]},
9379
"executableEntrypoint": {"type": ["string", "null"]},
@@ -114,7 +100,7 @@
114100
"artifact_type": {"type": "string"},
115101
"language": {"type": "string"},
116102
"typeName": {"type": "string", "pattern": TYPE_NAME_HOOK_REGEX},
117-
"runtime": {"type": "string", "enum": list(LAMBDA_RUNTIMES)},
103+
"runtime": {"type": "string"},
118104
"entrypoint": {"type": ["string", "null"]},
119105
"testEntrypoint": {"type": ["string", "null"]},
120106
"settings": {"type": "object"},
@@ -339,12 +325,6 @@ def _write_example_inputs(self):
339325
)
340326

341327
def write_settings(self):
342-
if self.runtime not in LAMBDA_RUNTIMES:
343-
LOG.critical(
344-
"Plugin returned invalid runtime: %s (%s)", self.runtime, self.language
345-
)
346-
raise InternalError("Internal error (Plugin returned invalid runtime)")
347-
348328
def _write_resource_settings(f):
349329
executable_entrypoint_dict = (
350330
{"executableEntrypoint": self.executable_entrypoint}

tests/test_project.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
from rpdk.core.project import (
3131
CFN_METADATA_FILENAME,
3232
CONFIGURATION_SCHEMA_UPLOAD_FILENAME,
33-
LAMBDA_RUNTIMES,
3433
OVERRIDES_FILENAME,
3534
SCHEMA_UPLOAD_FILENAME,
3635
SETTINGS_FILENAME,
@@ -53,7 +52,22 @@
5352
HOOK_TYPE_NAME = "AWS::CFN::HOOK"
5453
REGION = "us-east-1"
5554
ENDPOINT = "cloudformation.beta.com"
56-
RUNTIME = random.choice(list(LAMBDA_RUNTIMES))
55+
RUNTIME = random.choice(
56+
[
57+
"noexec", # cannot be executed, schema only
58+
"java8",
59+
"java11",
60+
"go1.x",
61+
"python3.7",
62+
"python3.8",
63+
"python3.9",
64+
"dotnetcore2.1",
65+
"nodejs10.x",
66+
"nodejs12.x",
67+
"nodejs14.x",
68+
"nodejs16.x",
69+
]
70+
)
5771
BLANK_CLIENT_ERROR = {"Error": {"Code": "", "Message": ""}}
5872
LOG = logging.getLogger(__name__)
5973
REGISTRATION_TOKEN = "foo"
@@ -2132,14 +2146,6 @@ def test__wait_for_registration_waiter_fails_describe_fails(project):
21322146
mock_waiter.wait.assert_called_once_with(RegistrationToken=REGISTRATION_TOKEN)
21332147

21342148

2135-
def test__write_settings_invalid_runtime(project):
2136-
project.runtime = "foo"
2137-
project.language = LANGUAGE
2138-
2139-
with pytest.raises(InternalError):
2140-
project.write_settings()
2141-
2142-
21432149
@pytest.mark.parametrize(
21442150
"docs_schema",
21452151
(

0 commit comments

Comments
 (0)