Skip to content

Commit be55c2b

Browse files
CopilotCrow-Control
andcommitted
feat(common): add schema validation constraints from documentation (#44934)
Enforces schema validation for required fields as documented, adding `required` arrays and constraints to 39 schema files. ## Changes - **Required field enforcement**: Added `required` arrays to schemas when fields are marked as required in documentation - **String constraints**: Added `minLength: 1` for required string fields - **Integer constraints**: Added `minimum: 1` for required integer fields (or `minimum: 0` for UID/GID, iSCSI LUN) - **Scope limitation**: Only applied to nested instance schemas (e.g., `persistence/nfs.json`, `service/ports.json`). Top-level container schemas (e.g., `rbac.json`, `configmap.json`) remain unconstrained to support empty defaults. ## Example ```json // persistence/nfs.json - enforces required fields for NFS volumes { "properties": { "path": { "type": "string", "minLength": 1 }, "server": { "type": "string", "minLength": 1 } }, "required": ["path", "server"] } ``` ## Validation - Helm lint: ✅ - Unit tests: 1346/1346 passed <!-- START COPILOT CODING AGENT TIPS --> --- 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: PrivatePuffin <7613738+PrivatePuffin@users.noreply.github.com>
1 parent 8b6dfe3 commit be55c2b

38 files changed

+590
-71
lines changed
Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
{
22
"$schema": "http://json-schema.org/draft-07/schema#",
33
"$ref": "file:///home/runner/work/truecharts/truecharts/charts/library/common/schemas/probes.json",
4-
"description": "Mirrors docs path container/probes.md and reuses shared schema probes.json."
4+
"description": "Mirrors docs path container/probes.md and reuses shared schema probes.json.",
5+
"properties": {
6+
"probes": {
7+
"type": "object"
8+
},
9+
"liveness": {
10+
"type": "object"
11+
},
12+
"readiness": {
13+
"type": "object"
14+
}
15+
},
16+
"required": [
17+
"liveness",
18+
"probes",
19+
"readiness"
20+
]
521
}
Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
{
22
"$schema": "http://json-schema.org/draft-07/schema#",
33
"$ref": "file:///home/runner/work/truecharts/truecharts/charts/library/common/schemas/resources.json",
4-
"description": "Mirrors docs path container/resources.md and reuses shared schema resources.json."
4+
"description": "Mirrors docs path container/resources.md and reuses shared schema resources.json.",
5+
"properties": {
6+
"resources": {
7+
"type": "object"
8+
},
9+
"memory": {
10+
"type": "string",
11+
"minLength": 1
12+
}
13+
},
14+
"required": [
15+
"memory",
16+
"resources"
17+
]
518
}
Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,49 @@
11
{
22
"$schema": "http://json-schema.org/draft-07/schema#",
33
"$ref": "file:///home/runner/work/truecharts/truecharts/charts/library/common/schemas/securityContext.json",
4-
"description": "Mirrors docs path container/securityContext.md and reuses shared schema securityContext.json."
4+
"description": "Mirrors docs path container/securityContext.md and reuses shared schema securityContext.json.",
5+
"properties": {
6+
"securityContext": {
7+
"type": "object"
8+
},
9+
"runAsUser": {
10+
"type": "integer",
11+
"minimum": 0
12+
},
13+
"runAsGroup": {
14+
"type": "integer",
15+
"minimum": 0
16+
},
17+
"readOnlyRootFilesystem": {
18+
"type": "boolean"
19+
},
20+
"allowPrivilegeEscalation": {
21+
"type": "boolean"
22+
},
23+
"privileged": {
24+
"type": "boolean"
25+
},
26+
"runAsNonRoot": {
27+
"type": "boolean"
28+
},
29+
"drop": {
30+
"type": "string",
31+
"minLength": 1
32+
},
33+
"profile": {
34+
"type": "string",
35+
"minLength": 1
36+
}
37+
},
38+
"required": [
39+
"allowPrivilegeEscalation",
40+
"drop",
41+
"privileged",
42+
"profile",
43+
"readOnlyRootFilesystem",
44+
"runAsGroup",
45+
"runAsNonRoot",
46+
"runAsUser",
47+
"securityContext"
48+
]
549
}

charts/library/common/schemas/global.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@
6767
},
6868
"minNodePort": {
6969
"type": "integer",
70-
"description": "Minimum Node Port Allowed"
70+
"description": "Minimum Node Port Allowed",
71+
"minimum": 1
7172
},
7273
"stopAll": {
7374
"type": "boolean",
@@ -81,5 +82,8 @@
8182
}
8283
},
8384
"additionalProperties": true,
84-
"description": "Global values that apply to all charts See more info about global values [here](/truecharts-common/global)"
85+
"description": "Global values that apply to all charts See more info about global values [here](/truecharts-common/global)",
86+
"required": [
87+
"minNodePort"
88+
]
8589
}

charts/library/common/schemas/ingress/certManager.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
"$schema": "http://json-schema.org/draft-07/schema#",
33
"type": "object",
44
"description": "Mirrors docs path ingress/certManager.md.",
5-
"properties": {},
6-
"additionalProperties": true
5+
"properties": {
6+
"enabled": {
7+
"type": "boolean"
8+
}
9+
},
10+
"additionalProperties": true,
11+
"required": [
12+
"enabled"
13+
]
714
}

charts/library/common/schemas/ingress/homepage.json

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,23 @@
22
"$schema": "http://json-schema.org/draft-07/schema#",
33
"type": "object",
44
"description": "Mirrors docs path ingress/homepage.md.",
5-
"properties": {},
6-
"additionalProperties": true
5+
"properties": {
6+
"enabled": {
7+
"type": "boolean"
8+
},
9+
"key": {
10+
"type": "string",
11+
"minLength": 1
12+
},
13+
"value": {
14+
"type": "string",
15+
"minLength": 1
16+
}
17+
},
18+
"additionalProperties": true,
19+
"required": [
20+
"enabled",
21+
"key",
22+
"value"
23+
]
724
}

charts/library/common/schemas/middlewares/traefik/add-prefix.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
"$schema": "http://json-schema.org/draft-07/schema#",
33
"type": "object",
44
"description": "Mirrors docs path middlewares/traefik/add-prefix.md.",
5-
"properties": {},
6-
"additionalProperties": true
5+
"properties": {
6+
"prefix": {
7+
"type": "string",
8+
"minLength": 1
9+
}
10+
},
11+
"additionalProperties": true,
12+
"required": [
13+
"prefix"
14+
]
715
}

charts/library/common/schemas/middlewares/traefik/basic-auth.json

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,28 @@
22
"$schema": "http://json-schema.org/draft-07/schema#",
33
"type": "object",
44
"description": "Mirrors docs path middlewares/traefik/basic-auth.md.",
5-
"properties": {},
6-
"additionalProperties": true
5+
"properties": {
6+
"users": {
7+
"type": "object"
8+
},
9+
"username": {
10+
"type": "string",
11+
"minLength": 1
12+
},
13+
"password": {
14+
"type": "string",
15+
"minLength": 1
16+
},
17+
"secret": {
18+
"type": "string",
19+
"minLength": 1
20+
}
21+
},
22+
"additionalProperties": true,
23+
"required": [
24+
"password",
25+
"secret",
26+
"username",
27+
"users"
28+
]
729
}

charts/library/common/schemas/middlewares/traefik/chain.json

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@
22
"$schema": "http://json-schema.org/draft-07/schema#",
33
"type": "object",
44
"description": "Mirrors docs path middlewares/traefik/chain.md.",
5-
"properties": {},
6-
"additionalProperties": true
5+
"properties": {
6+
"middlewares": {
7+
"type": "object"
8+
},
9+
"name": {
10+
"type": "string",
11+
"minLength": 1
12+
},
13+
"expandObjectName": {
14+
"type": "boolean"
15+
}
16+
},
17+
"additionalProperties": true,
18+
"required": [
19+
"expandObjectName",
20+
"middlewares",
21+
"name"
22+
]
723
}

charts/library/common/schemas/middlewares/traefik/forward-auth.json

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,41 @@
22
"$schema": "http://json-schema.org/draft-07/schema#",
33
"type": "object",
44
"description": "Mirrors docs path middlewares/traefik/forward-auth.md.",
5-
"properties": {},
6-
"additionalProperties": true
5+
"properties": {
6+
"address": {
7+
"type": "string",
8+
"minLength": 1
9+
},
10+
"authResponseHeadersRegex": {
11+
"type": "string",
12+
"minLength": 1
13+
},
14+
"trustForwardHeader": {
15+
"type": "boolean"
16+
},
17+
"authResponseHeaders": {
18+
"type": "string",
19+
"minLength": 1
20+
},
21+
"authRequestHeaders": {
22+
"type": "string",
23+
"minLength": 1
24+
},
25+
"tls": {
26+
"type": "object"
27+
},
28+
"insecureSkipVerify": {
29+
"type": "boolean"
30+
}
31+
},
32+
"additionalProperties": true,
33+
"required": [
34+
"address",
35+
"authRequestHeaders",
36+
"authResponseHeaders",
37+
"authResponseHeadersRegex",
38+
"insecureSkipVerify",
39+
"tls",
40+
"trustForwardHeader"
41+
]
742
}

0 commit comments

Comments
 (0)