Skip to content

Commit 6c99760

Browse files
authored
Convert resolver errors to warnings (#3493)
1 parent b56947d commit 6c99760

24 files changed

+219
-60
lines changed

src/cfnlint/rules/functions/FindInMap.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ class FindInMap(BaseFn):
2121
tags = ["functions", "findinmap"]
2222

2323
def __init__(self) -> None:
24-
super().__init__("Fn::FindInMap", ("array",) + singular_types)
24+
super().__init__(
25+
"Fn::FindInMap", ("array",) + singular_types, resolved_rule="W1034"
26+
)
2527

2628
def schema(self, validator: Validator, instance: Any) -> dict[str, Any]:
2729
scalar_schema = {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
SPDX-License-Identifier: MIT-0
4+
"""
5+
6+
from cfnlint.rules import CloudFormationLintRule
7+
8+
9+
class FindInMapResolved(CloudFormationLintRule):
10+
id = "W1034"
11+
shortdesc = "Validate the values that come from a Fn::FindInMap function"
12+
description = (
13+
"Resolve the Fn::FindInMap and then validate the values against the schema"
14+
)
15+
source_url = "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-findinmap.html"
16+
tags = ["functions", "findinmap"]

src/cfnlint/rules/functions/GetAz.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class GetAz(BaseFn):
2222
tags = ["functions", "getaz"]
2323

2424
def __init__(self) -> None:
25-
super().__init__("Fn::GetAZs", ("array",), ("Ref",))
25+
super().__init__("Fn::GetAZs", ("array",), ("Ref",), resolved_rule="W1036")
2626
self.fn_getazs = self.validate
2727

2828
def schema(self, validator: Validator, instance: Any) -> dict[str, Any]:
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
SPDX-License-Identifier: MIT-0
4+
"""
5+
6+
from cfnlint.rules import CloudFormationLintRule
7+
8+
9+
class FindInMapResolved(CloudFormationLintRule):
10+
id = "W1036"
11+
shortdesc = "Validate the values that come from a Fn::GetAZs function"
12+
description = (
13+
"Resolve the Fn::GetAZs and then validate the values against the schema"
14+
)
15+
source_url = "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-getavailabilityzones.html"
16+
tags = ["functions", "getazs"]

src/cfnlint/rules/functions/Join.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ class Join(BaseFn):
2222
tags = ["functions", "join"]
2323

2424
def __init__(self) -> None:
25-
super().__init__("Fn::Join", ("string",))
26-
self.child_rules = {
27-
"I1022": None,
28-
}
25+
super().__init__("Fn::Join", ("string",), resolved_rule="W1032")
26+
self.child_rules.update(
27+
{
28+
"I1022": None,
29+
}
30+
)
2931

3032
def schema(self, validator, instance) -> dict[str, Any]:
3133
return {
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
"""
2+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
SPDX-License-Identifier: MIT-0
4+
"""
5+
6+
from cfnlint.rules import CloudFormationLintRule
7+
8+
9+
class JoinResolved(CloudFormationLintRule):
10+
id = "W1032"
11+
shortdesc = "Validate the values that come from a Fn::Join function"
12+
description = "Resolve the Fn::Join and then validate the values against the schema"
13+
source_url = "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-join.html"
14+
tags = ["functions", "join"]

src/cfnlint/rules/functions/Ref.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ class Ref(BaseFn):
2222
tags = ["functions", "ref"]
2323

2424
def __init__(self) -> None:
25-
super().__init__("Ref", all_types)
25+
super().__init__("Ref", all_types, resolved_rule="W1030")
2626
self._all_refs = [
2727
"W2010",
2828
]
29-
self.child_rules = dict.fromkeys(self._all_refs)
29+
self.child_rules.update(dict.fromkeys(self._all_refs))
3030

3131
def schema(self, validator, instance) -> dict[str, Any]:
3232
return {
@@ -94,5 +94,7 @@ def ref(self, validator, subschema, instance, schema):
9494
for rule in self.child_rules.values():
9595
if not rule or rule.id in self._all_refs:
9696
continue
97+
if not hasattr(rule, "keywords"):
98+
continue
9799
if keyword in rule.keywords:
98100
yield from rule.validate(validator, keyword, instance, schema)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
"""
2+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
SPDX-License-Identifier: MIT-0
4+
"""
5+
6+
from cfnlint.rules import CloudFormationLintRule
7+
8+
9+
class RefResolved(CloudFormationLintRule):
10+
id = "W1030"
11+
shortdesc = "Validate the values that come from a Ref function"
12+
description = "Resolve the Ref and then validate the values against the schema"
13+
source_url = "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html"
14+
tags = ["functions", "ref"]

src/cfnlint/rules/functions/Select.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Select(BaseFn):
2121
tags = ["functions", "select"]
2222

2323
def __init__(self) -> None:
24-
super().__init__("Fn::Select", all_types)
24+
super().__init__("Fn::Select", all_types, resolved_rule="W1035")
2525
self.fn_select = self.validate
2626

2727
def schema(self, validator: Validator, instance: Any) -> dict[str, Any]:
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
SPDX-License-Identifier: MIT-0
4+
"""
5+
6+
from cfnlint.rules import CloudFormationLintRule
7+
8+
9+
class SelectResolved(CloudFormationLintRule):
10+
id = "W1035"
11+
shortdesc = "Validate the values that come from a Fn::Select function"
12+
description = (
13+
"Resolve the Fn::Select and then validate the values against the schema"
14+
)
15+
source_url = "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-select.html"
16+
tags = ["functions", "select"]

0 commit comments

Comments
 (0)