forked from aws-cloudformation/cfn-lint
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Or.py
50 lines (41 loc) · 1.46 KB
/
Or.py
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
49
50
"""
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: MIT-0
"""
from __future__ import annotations
from typing import Any
from cfnlint.helpers import FUNCTION_RULES
from cfnlint.jsonschema import Validator
from cfnlint.rules.functions._BaseFn import BaseFn
class Or(BaseFn):
"""Check Or Condition Function Logic"""
id = "E8006"
shortdesc = "Check Fn::Or structure for validity"
description = "Check Fn::Or 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-or"
tags = ["functions", "or"]
def __init__(self) -> None:
super().__init__("Fn::Or", ("boolean",))
self.fn_or = self.validate
def schema(self, validator: Validator, instance: Any) -> dict[str, Any]:
if validator.context.path.path and validator.context.path.path[0] == "Rules":
functions = list(FUNCTION_RULES)
else:
functions = [
"Condition",
"Fn::Equals",
"Fn::Not",
"Fn::And",
"Fn::Or",
]
return {
"type": "array",
"minItems": 2,
"maxItems": 10,
"fn_items": {
"functions": functions,
"schema": {
"type": ["boolean"],
},
},
}