Skip to content

Commit 60b04fe

Browse files
authored
Adds helm schema validation (#252)
Issue #, if available: Closes aws-controllers-k8s/community#899 Description of changes: This adds a JSON schema to validate inputs to the helm chart, so that values of an incorrect type, regex or enumeration will fail quickly, rather than after the helm deployment runs. Please let me know if I've missed any of the enum options. Also worth noting that regarding the types, this will break functionality for anyone using `"true"`, `"false"`, `1`, `0` as a boolean or `"42"` as an integer, so let me know if you want those added as additional options to those fields. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 06f01f2 commit 60b04fe

File tree

2 files changed

+212
-0
lines changed

2 files changed

+212
-0
lines changed

pkg/generate/ack/release.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ var (
2727
"helm/templates/cluster-role-binding.yaml.tpl",
2828
"helm/Chart.yaml.tpl",
2929
"helm/values.yaml.tpl",
30+
"helm/values.schema.json",
3031
"helm/templates/role-reader.yaml.tpl",
3132
"helm/templates/role-writer.yaml.tpl",
3233
"helm/templates/_controller-role-kind-patch.yaml.tpl",

templates/helm/values.schema.json

Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
{
2+
"$schema": "https://json-schema.org/draft-07/schema#",
3+
"properties": {
4+
"image": {
5+
"description": "Container Image",
6+
"properties": {
7+
"repository": {
8+
"type": "string",
9+
"minLength": 1
10+
},
11+
"tag": {
12+
"type": "string",
13+
"minLength": 1
14+
},
15+
"pullPolicy": {
16+
"type": "string",
17+
"enum": ["IfNotPresent", "Always", "Never"]
18+
},
19+
"pullSecrets": {
20+
"type": "array"
21+
}
22+
},
23+
"required": [
24+
"repository",
25+
"tag",
26+
"pullPolicy"
27+
],
28+
"type": "object"
29+
},
30+
"nameOverride": {
31+
"type": "string"
32+
},
33+
"fullNameOverride": {
34+
"type": "string"
35+
},
36+
"deployment": {
37+
"description": "Deployment settings",
38+
"properties": {
39+
"annotations": {
40+
"type": "object"
41+
},
42+
"labels": {
43+
"type": "object"
44+
},
45+
"containerPort": {
46+
"type": "integer",
47+
"minimum": 1,
48+
"maximum": 65535
49+
},
50+
"nodeSelector": {
51+
"type": "object"
52+
},
53+
"tolerations": {
54+
"type": "object"
55+
},
56+
"affinity": {
57+
"type": "object"
58+
},
59+
"priorityClassName": {
60+
"type": "string"
61+
}
62+
},
63+
"required": [
64+
"containerPort"
65+
],
66+
"type": "object"
67+
},
68+
"metrics": {
69+
"description": "Metrics settings",
70+
"properties": {
71+
"service": {
72+
"description": "Kubernetes service settings",
73+
"properties": {
74+
"create": {
75+
"type": "boolean"
76+
},
77+
"type": {
78+
"type": "string",
79+
"enum": ["ClusterIP", "NodePort", "LoadBalancer", "ExternalName"]
80+
}
81+
},
82+
"required": [
83+
"create",
84+
"type"
85+
],
86+
"type": "object"
87+
}
88+
},
89+
"required": [
90+
"service"
91+
],
92+
"type": "object"
93+
},
94+
"resources": {
95+
"description": "Kubernetes resources settings",
96+
"properties": {
97+
"requests": {
98+
"description": "Kubernetes resource requests",
99+
"properties": {
100+
"memory": {
101+
"oneOf": [
102+
{ "type": "number" },
103+
{ "type": "string" }
104+
]
105+
},
106+
"cpu": {
107+
"oneOf": [
108+
{ "type": "number" },
109+
{ "type": "string" }
110+
]
111+
}
112+
},
113+
"required": [
114+
"memory",
115+
"cpu"
116+
],
117+
"type": "object"
118+
},
119+
"limits": {
120+
"description": "Kubernetes resource limits",
121+
"properties": {
122+
"memory": {
123+
"oneOf": [
124+
{ "type": "number" },
125+
{ "type": "string" }
126+
]
127+
},
128+
"cpu": {
129+
"oneOf": [
130+
{ "type": "number" },
131+
{ "type": "string" }
132+
]
133+
}
134+
},
135+
"required": [
136+
"memory",
137+
"cpu"
138+
],
139+
"type": "object"
140+
}
141+
},
142+
"required": [
143+
"requests",
144+
"limits"
145+
],
146+
"type": "object"
147+
},
148+
"aws": {
149+
"description": "AWS API settings",
150+
"properties": {
151+
"region": {
152+
"type": "string"
153+
},
154+
"endpoint": {
155+
"type": "string"
156+
}
157+
},
158+
"type": "object"
159+
},
160+
"log": {
161+
"description": "Logging settings",
162+
"properties": {
163+
"enable_development_logging": {
164+
"type": "boolean"
165+
},
166+
"level": {
167+
"type": "string"
168+
}
169+
},
170+
"type": "object"
171+
},
172+
"installScope": {
173+
"type": "string",
174+
"enum": ["cluster", "namespace"]
175+
},
176+
"resourceTags": {
177+
"type": "array",
178+
"items": {
179+
"type": "string",
180+
"pattern": "^.*=.*$"
181+
}
182+
},
183+
"serviceAccount": {
184+
"description": "ServiceAccount settings",
185+
"properties": {
186+
"create": {
187+
"type": "boolean"
188+
},
189+
"name": {
190+
"type": "string"
191+
},
192+
"annotations": {
193+
"type": "object"
194+
}
195+
},
196+
"type": "object"
197+
}
198+
},
199+
"required": [
200+
"image",
201+
"deployment",
202+
"metrics",
203+
"resources",
204+
"log",
205+
"installScope",
206+
"resourceTags",
207+
"serviceAccount"
208+
],
209+
"title": "Values",
210+
"type": "object"
211+
}

0 commit comments

Comments
 (0)