-
Notifications
You must be signed in to change notification settings - Fork 0
/
validators.go
executable file
·62 lines (52 loc) · 1.81 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 keboola
import (
"fmt"
"strings"
)
func validateAccessTokenBucketPermissions(v interface{}, k string) (ws []string, errors []error) {
values := v.(map[string]interface{})
for key, value := range values {
if value != "read" && value != "write" && value != "manage" {
errors = append(errors, fmt.Errorf(
"%q must be set to one of %s, %s or %s, got %q for '%q'",
k, "read", "write", "manage", value, key))
}
}
return
}
func validateStorageBucketStage(v interface{}, k string) (ws []string, errors []error) {
value := v.(string)
if value != "in" && value != "out" && value != "sys" {
errors = append(errors, fmt.Errorf(
"%q must be set to one of %s, %s or %s, got %q",
k, "in", "out", "sys", value))
}
return
}
func validateStorageBucketBackend(v interface{}, k string) (ws []string, errors []error) {
if value := v.(string); value != "" {
if value != "snowflake" && value != "mysql" && value != "redshift" {
errors = append(errors, fmt.Errorf(
"%q must be set to one of %s, %s or %s, got %q",
k, "snowflake", "mysql", "redshift", value))
}
}
return
}
func validateOrchestrationNotificationChannel(v interface{}, k string) (ws []string, errors []error) {
value := v.(string)
if value != "error" && value != "warning" && value != "processing" {
errors = append(errors, fmt.Errorf(
"%q must be set to one of %s, %s or %s, got %q",
k, "error", "warning", "processing", value))
}
return
}
func validateKBCEncryptedValue(v interface{}, k string) (ws []string, errors []error) {
value := v.(string)
if !strings.HasPrefix(value, "KBC::ProjectSecure::") {
errors = append(errors, fmt.Errorf(
"%q must be a value encrypted using the KBC Encryption API (https://developers.keboola.com/overview/encryption/), and is expected to start with 'KBC::ProjectSecure::'", k))
}
return
}