-
Notifications
You must be signed in to change notification settings - Fork 0
/
selection_rules.go
50 lines (42 loc) · 1.04 KB
/
selection_rules.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package arpio
const (
ArnRuleType = "arn"
TagRuleType = "tag"
)
type SelectionRule interface {
GetRuleType() string
}
// Embeddable struct to assist with polymorphic unmarshaling of rule types.
type selectionRule struct {
RuleType string `json:"ruleType"`
}
// GetRuleType returns the rule type.
func (r selectionRule) GetRuleType() string {
return r.RuleType
}
type ArnRule struct {
selectionRule
Arns []string `json:"arns"`
}
// NewArnRule creates an ArnRule that will match resources with the
// specified ARN strings.
func NewArnRule(arns []string) ArnRule {
return ArnRule{
selectionRule: selectionRule{RuleType: ArnRuleType},
Arns: arns,
}
}
type TagRule struct {
selectionRule
Name string `json:"name"`
Value string `json:"value"`
}
// NewTagRule creates an TagRule that will match resources with the
// specified tag name and value (which may be empty).
func NewTagRule(name, value string) TagRule {
return TagRule{
selectionRule: selectionRule{RuleType: TagRuleType},
Name: name,
Value: value,
}
}