(pa AttributeFilter, attrs []*commonv1.KeyValue)
| 40 | } |
| 41 | |
| 42 | func matchesAnyFilter(pa AttributeFilter, attrs []*commonv1.KeyValue) bool { |
| 43 | for _, attr := range attrs { |
| 44 | // If the attribute key does not match, then it cannot match the policy. |
| 45 | if pa.key != attr.Key { |
| 46 | continue |
| 47 | } |
| 48 | switch pa.typ { |
| 49 | case StringAttributeFilter: |
| 50 | return pa.stringValue == attr.Value.GetStringValue() |
| 51 | case Int64AttributeFilter: |
| 52 | return pa.int64Value == attr.Value.GetIntValue() |
| 53 | case Float64AttributeFilter: |
| 54 | return pa.float64Value == attr.Value.GetDoubleValue() |
| 55 | case BoolAttributeFilter: |
| 56 | return pa.boolValue == attr.Value.GetBoolValue() |
| 57 | case RegexAttributeFilter: |
| 58 | return pa.regex.MatchString(attr.Value.GetStringValue()) |
| 59 | } |
| 60 | } |
| 61 | return false |
| 62 | } |
| 63 | |
| 64 | type AttributeFilterType int |
| 65 |
no test coverage detected