Skip to content
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

Load registry schemas if type match #3450

Merged
merged 4 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add tests and cleanup code
  • Loading branch information
kddejong committed Jul 1, 2024
commit 2f8e927d3c9a91f8a5e7e7efe66efa9964ee7dfa
2 changes: 1 addition & 1 deletion src/cfnlint/schema/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def get_resource_schema(self, region: str, resource_type: str) -> Schema:
rt = ToPy(resource_type)

if resource_type not in self._registry_schemas:
resource_type = self._normalize_resource_type(resource_type)
rt = ToPy(self._normalize_resource_type(resource_type))

if resource_type in self._removed_types:
raise ResourceNotFoundError(resource_type, region)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,11 @@ Resources:
- !Ref 'AWS::NoValue'
BadType:
Type: !Ref AWS::Region
Module1:
Type: MyCompany::MODULE
Properties:
Attribute1: test
Module2:
Type: MyCompany::MODULE
Properties:
Attribute2: test
12 changes: 12 additions & 0 deletions test/unit/module/schema/test_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,3 +271,15 @@ def test_removed_types(self):

with self.assertRaises(ResourceNotFoundError):
self.manager.get_resource_schema(region, rt)

def test_type_normalization(self):

rt = "MyCompany::MODULE"
schema = self.manager.get_resource_schema("us-east-1", rt)

assert schema.schema.get("typeName") == "Module"

self.manager.get_resource_schema.cache_clear()
self.manager._registry_schemas[rt] = True
schema = self.manager.get_resource_schema("us-east-1", rt)
assert schema is True