Skip to content

Commit

Permalink
Fix an issue with path in SnapStart
Browse files Browse the repository at this point in the history
  • Loading branch information
kddejong committed May 23, 2024
1 parent dd31e20 commit a654a47
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/cfnlint/data/schemas/other/resources/configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@
],
"then": {
"properties": {
"CreationPolicy": false,
"UpdatePolicy": false,
"Version": {
"type": "string"
},
"CreationPolicy": false,
"UpdatePolicy": false
}
}
},
"type": "object"
Expand Down
11 changes: 7 additions & 4 deletions src/cfnlint/data/schemas/other/resources/metadata.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
{
"additionalProperties": {
"type": ["object", "string"]
"type": [
"object",
"string"
]
},
"properties": {
"AWS::CloudFormation::Init": {
"type": "object",
"properties": {},
"additionalProperties": true
"additionalProperties": true,
"properties": {},
"type": "object"
}
},
"type": [
Expand Down
2 changes: 1 addition & 1 deletion src/cfnlint/rules/resources/lmbd/SnapStart.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def validate(self, validator, _, instance, schema):
if instance != "PublishedVersions":
return

resource_name = validator.context.path[1]
resource_name = validator.context.path.path[1]
lambda_version_type = "AWS::Lambda::Version"
if list(
validator.cfn.get_resource_children(resource_name, [lambda_version_type])
Expand Down
1 change: 1 addition & 0 deletions test/integration/test_schema_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class TestSchemaFiles(TestCase):
"Outputs/*/Value",
"Parameters",
"Parameters/*",
"Resources",
"Resources/*",
"Resources/*/DeletionPolicy",
"Resources/*/DependsOn",
Expand Down
15 changes: 13 additions & 2 deletions test/unit/rules/resources/lmbd/test_snapstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import pytest

from cfnlint.context import Context
from cfnlint.context import Context, Path
from cfnlint.jsonschema import CfnTemplateValidator, ValidationError
from cfnlint.rules.resources.lmbd.SnapStart import SnapStart
from cfnlint.template import Template
Expand Down Expand Up @@ -96,7 +96,18 @@ def validator():
def test_validate(name, instance, path, expected, rule, validator):
validator = validator.evolve(
context=Context(
path=path,
path=Path(
path=path,
cfn_path=deque(
[
"Resources",
"AWS::Lambda::Function",
"Properties",
"SnapStart",
"ApplyOn",
]
),
)
)
)
errs = list(rule.validate(validator, "", instance, {}))
Expand Down

0 comments on commit a654a47

Please sign in to comment.