@@ -8,19 +8,52 @@ import (
88func GetValidator (variableKind string ) func (string ) error {
99 switch variableKind {
1010 case "envVarMap" :
11- return KeyValueMapValidator
11+ return keyValueMapValidator
12+ case "imagePullPolicy" :
13+ return imagePullPolicyValidator
14+ case "kubernetesProbeType" :
15+ return kubernetesProbeTypeValidator
16+ case "scalingResourceType" :
17+ return scalingResourceTypeValidator
1218 default :
13- return DefaultValidator
19+ return defaultValidator
1420 }
1521}
1622
17- func KeyValueMapValidator (input string ) error {
23+ func imagePullPolicyValidator (input string ) error {
24+ switch input {
25+ case "Always" , "IfNotPresent" , "Never" :
26+ return nil
27+ default :
28+ return fmt .Errorf ("invalid image pull policy: %s" , input )
29+ }
30+ }
31+
32+ func scalingResourceTypeValidator (input string ) error {
33+ switch input {
34+ case "cpu" , "memory" :
35+ return nil
36+ default :
37+ return fmt .Errorf ("invalid scaling resource type: %s" , input )
38+ }
39+ }
40+
41+ func kubernetesProbeTypeValidator (input string ) error {
42+ switch input {
43+ case "httpGet" , "tcpSocket" :
44+ return nil
45+ default :
46+ return fmt .Errorf ("invalid probe type: %s" , input )
47+ }
48+ }
49+
50+ func keyValueMapValidator (input string ) error {
1851 if err := json .Unmarshal ([]byte (input ), & map [string ]string {}); err != nil {
1952 return fmt .Errorf ("failed to unmarshal variable as map[string]string: %s" , err )
2053 }
2154 return nil
2255}
2356
24- func DefaultValidator (input string ) error {
57+ func defaultValidator (input string ) error {
2558 return nil
2659}
0 commit comments