forked from aws-cloudformation/cfn-lint
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEquals.py
More file actions
48 lines (39 loc) · 1.54 KB
/
Equals.py
File metadata and controls
48 lines (39 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
"""
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: MIT-0
"""
from __future__ import annotations
from typing import Any
import cfnlint.data.schemas.other.functions
from cfnlint.jsonschema import ValidationResult, Validator
from cfnlint.rules.functions._BaseFn import BaseFn, SchemaDetails
class Equals(BaseFn):
"""Check Equals Condition Function Logic"""
id = "E8003"
shortdesc = "Check Fn::Equals structure for validity"
description = "Check Fn::Equals is a list of two elements"
source_url = "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-conditions.html#intrinsic-function-reference-conditions-equals"
tags = ["functions", "equals"]
def __init__(self) -> None:
super().__init__(
"Fn::Equals",
("boolean",),
schema_details=SchemaDetails(
cfnlint.data.schemas.other.functions, "equals.json"
),
)
self.child_rules = {
"W8003": None,
}
def fn_equals(
self, validator: Validator, s: Any, instance: Any, schema: Any
) -> ValidationResult:
errs = list(self.validate(validator, s, instance, schema))
if errs:
yield from iter(errs)
return
child_rule = self.child_rules.get("W8003")
if child_rule and hasattr(child_rule, "equals_is_useful"):
yield from child_rule.equals_is_useful(
validator, s, instance.get("Fn::Equals", []), schema
)