Skip to content

Commit

Permalink
Allow Transform section to have the full transform def
Browse files Browse the repository at this point in the history
  • Loading branch information
kddejong committed Jul 6, 2024
1 parent 9f6e8f4 commit 8011612
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/cfnlint/context/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __post_init__(self, transforms) -> None:

for transform in transforms:
if not isinstance(transform, str):
raise ValueError("Transform must be a string")
continue
self._transforms.append(transform)

def has_language_extensions_transform(self):
Expand Down
37 changes: 35 additions & 2 deletions src/cfnlint/data/schemas/other/template/configuration.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
{
"additionalProperties": false,
"definitions": {
"Transform": {
"properties": {
"Name": {
"type": "string"
},
"Properties": {
"patternProperties": {
".*": {
"type": [
"string",
"array",
"boolean",
"object",
"number",
"integer"
]
}
},
"type": "object"
}
},
"required": [
"Name"
]
}
},
"properties": {
"AWSTemplateFormatVersion": {
"enum": [
Expand All @@ -23,12 +50,18 @@
"type": "object"
},
"Transform": {
"$ref": "#/definitions/Transform",
"items": {
"type": "string"
"$ref": "#/definitions/Transform",
"type": [
"string",
"object"
]
},
"type": [
"string",
"array"
"array",
"object"
]
}
},
Expand Down
17 changes: 5 additions & 12 deletions test/unit/module/context/test_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
"name,instance,expected",
[
("Valid transforms", "AWS::LanguageExtensions", True),
("Valid transforms lists", ["AWS::LanguageExtensions"], True),
(
"Valid transforms lists",
["AWS::LanguageExtensions", {"Name": "Include"}],
True,
),
("Valid transforms lists", None, False),
("Valid transforms lists", "", False),
],
Expand All @@ -23,14 +27,3 @@ def test_transforms(name, instance, expected):
assert (
expected == transforms.has_language_extensions_transform()
), f"{name!r} test got {transforms.has_language_extensions_transform()}"


@pytest.mark.parametrize(
"name,instance",
[
("Invalid Type", {}),
],
)
def test_errors(name, instance):
with pytest.raises(ValueError):
Transforms(instance)

0 comments on commit 8011612

Please sign in to comment.