-
Notifications
You must be signed in to change notification settings - Fork 5
/
utils.go
61 lines (49 loc) · 1.01 KB
/
utils.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
51
52
53
54
55
56
57
58
59
60
61
package waf
import (
"github.com/aws/aws-sdk-go/service/wafv2"
)
func removesStringPtr(slice []*string, s string) []*string {
for i, item := range slice {
if *item == s {
return append(slice[:i], slice[i+1:]...)
}
}
return slice
}
func removesString(slice []string, s string) []string {
for i, item := range slice {
if item == s {
return append(slice[:i], slice[i+1:]...)
}
}
return slice
}
func removeRuleFromRuleGroup(rules []*wafv2.Rule, name string) []*wafv2.Rule {
for i, r := range rules {
if *r.Name == name {
return append(rules[:i], rules[i+1:]...)
}
}
return rules
}
func removeIpSetFromSlice(sets []*WAFIpSet, ipset *WAFIpSet) []*WAFIpSet {
for i, s := range sets {
if s == ipset {
return append(sets[:i], sets[i+1:]...)
}
}
return sets
}
func uniqueStrPtr(s []*string) []*string {
m := make(map[*string]bool)
for _, v := range s {
if _, ok := m[v]; !ok {
m[v] = true
}
}
var result []*string
for k := range m {
result = append(result, k)
}
return result
}