-
Notifications
You must be signed in to change notification settings - Fork 132
/
validators.go
62 lines (53 loc) · 1.34 KB
/
validators.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
62
package fastly
import "fmt"
func validateLoggingFormatVersion(v interface{}, k string) (ws []string, errors []error) {
value := uint(v.(int))
validVersions := map[uint]struct{}{
1: {},
2: {},
}
if _, ok := validVersions[value]; !ok {
errors = append(errors, fmt.Errorf(
"%q must be one of ['1', '2']", k))
}
return
}
func validateLoggingMessageType(v interface{}, k string) (ws []string, errors []error) {
value := v.(string)
validTypes := map[string]struct{}{
"classic": {},
"loggly": {},
"logplex": {},
"blank": {},
}
if _, ok := validTypes[value]; !ok {
errors = append(errors, fmt.Errorf(
"%q must be one of ['classic', 'loggly', 'logplex', 'blank']", k))
}
return
}
func validateLoggingPlacement(v interface{}, k string) (ws []string, errors []error) {
value := v.(string)
validTypes := map[string]struct{}{
"none": {},
"waf_debug": {},
}
if _, ok := validTypes[value]; !ok {
errors = append(errors, fmt.Errorf(
"%q must be one of ['none', 'waf_debug']", k))
}
return
}
func validateDirectorType(v interface{}, k string) (ws []string, errors []error) {
value := uint(v.(int))
validVersions := map[uint]struct{}{
1: {},
3: {},
4: {},
}
if _, ok := validVersions[value]; !ok {
errors = append(errors, fmt.Errorf(
"%q must be one of ['1' (random), '3' (hash), '4' (client)]", k))
}
return
}