-
Notifications
You must be signed in to change notification settings - Fork 193
/
fnor.go
28 lines (23 loc) · 680 Bytes
/
fnor.go
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
package intrinsics
// FnOr resolves the 'Fn::Or' AWS CloudFormation intrinsic function.
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-conditions.html#intrinsic-function-reference-conditions-or
func FnOr(name string, input interface{}, template interface{}) interface{} {
// "Fn::Or": [{condition}, ...]
// Check the input is an array
if arr, ok := input.([]interface{}); ok {
if len(arr) < 2 || len(arr) > 10 {
return nil
}
for _, c := range arr {
if value, ok := retrieveCondition(c, template); ok {
if value {
return true
}
} else {
return nil
}
}
return false
}
return nil
}