feat: add values.schema.json for service and cron-job charts#291
Conversation
Adds a JSON Schema (draft-07) describing the user-configurable values of the service chart. Covers ports, ingress, resources, autoscaling, probes, env, app secrets, command and alerts. Fields are annotated with `mutable: true` so the form renderer exposes them as editable fields.
45d2514 to
a162444
Compare
Adds a JSON Schema (draft-07) describing the user-configurable values of the cron-job chart. Covers schedule/suspend/concurrencyPolicy, command, ports, resources, env, app secrets and alerts. Fields are annotated with `mutable: true` so the form renderer exposes them as editable fields. envList[].value is typed string-only: cronJob.yaml emits envList via raw toYaml (unquoted), so a numeric/boolean value would render an invalid EnvVar that the API server rejects. The service chart keeps the broader type because it quotes envList into a ConfigMap.
a162444 to
1e1ad43
Compare
K8s container command is []string and both charts render it via `toJson`, so a string value produces an invalid manifest that the apiserver rejects. Narrow command to array/null in both schemas. - service: command type -> ["array", "null"] (default is already null) - cron-job: command type -> ["array", "null"], drop the "" default - cron-job values.yaml: change default command from "" to [] so the shipped default validates against the narrowed schema
Revert the values.yaml default back to command: "" (do not change the
shipped default). Instead, update the cron-job schema so that default
validates: command accepts array/null and the empty string only, while
a non-empty string is rejected via `not: {type: string, minLength: 1}`.
This keeps the existing values.yaml unchanged while still preventing the
invalid-manifest case the review flagged (a non-empty string rendered
through toJson into a K8s command, which is []string).
PiyushSingh-ZS
left a comment
There was a problem hiding this comment.
Reviewed against the diff, both charts' values.yaml + templates, and the reference schema (mariadb). Solid PR — both schemas follow the repo's established convention well. A few notes.
Alignment with the mariadb reference ✅
- draft-07 header,
mutable: trueon editable leaves (not onname), CPU/memorypatternregexes identical tomariadb, and noadditionalProperties: false(advanced keys stay valid) — all consistent. - Deviation: this PR adds a top-level
required: ["name","image"];mariadbhas no top-levelrequired. Harmless since both are non-mutable and always shipped — just flagging the departure from the reference.
Verified correct against the templates 👍
- cron-job
command:cronJob.yaml:63emitscommand: {{ tpl (toJson .Values.command) . }}. Thenot: { type: string, minLength: 1 }constraint correctly forbids a non-empty string (which would rendercommand: "foo"— invalid for a k8s[]string) while still permitting the shipped""default. Nice. - service
command: sametoJsonpattern atdeployment.yaml:125; schema types it["array","null"](no string), safe given itsnulldefault. The asymmetry with cron-job is correct — each matches its own default. hpaCPU/hpaMemoryas["string","null"]: matches thene "" / ne nilguards inhpa.yaml:20-36. Minor doc nit: the PR description says "typed as string" — they're actuallystring|null.- service
metricsPort(no default): correct — servicevalues.yamlships none, and templates gate on(ne (int .Values.metricsPort) 0).
Worth confirming
A few user-facing service keys are consumed by templates but omitted from the schema: replicaCount, minAvailable (PDB), metricsScrapeInterval, injectIstio, cliService. If the scope is strictly "fields the form manager renders," that's a fine call — just confirming each omission is deliberate.
|
Thanks for the thorough review, @PiyushSingh-ZS. Responding to each point: Omitted service keys — deliberate. Scope is strictly "fields the form manager renders as editable", so One clarification: Top-level Doc nit ( |
PiyushSingh-ZS
left a comment
There was a problem hiding this comment.
Thanks for the detailed responses — all points addressed. Confirmed replicaCount is indeed unused (only in values.yaml/README, never a template; deployment.yaml:18 uses minReplicas), so the omission is correct. Keep the top-level required: ["name","image"] — turning a downstream render failure into an early validation error is the better call. LGTM 🚀
Summary
Adds
values.schema.json(JSON Schema draft-07) for the service and cron-job charts, following the format used by the existing charts in this repo (e.g.mariadb). These schemas drive the editable form fields rendered by the form manager, which fetchescharts/<name>/values.schema.jsondirectly from themainbranch (no chart release/version bump required).Two commits, one per file:
feat(service): add values.schema.json for service chartfeat(cron-job): add values.schema.json for cron-job chartScope of fields
The schemas describe only the user-configurable values surfaced in the UI. Each editable field is annotated with
"mutable": true(a real boolean), andnameis intentionally left non-mutable.name,image,httpPort,metricsPort,ports,nginx,envFrom,minCPU/minMemory/maxCPU/maxMemory,minReplicas/maxReplicas,hpa_enable/hpaCPU/hpaMemory,heartbeatURL,readinessProbe,livenessProbe,env,envList,appSecrets,command,alertsname,image,schedule,suspend,concurrencyPolicy,command,httpPort,metricsPort,minCPU/minMemory/maxCPU/maxMemory,envFrom,env,envList,appSecrets,alertsAdvanced/internal keys (
keda,securityContext,initContainer,datastores,imagePullSecrets,volumeMounts, etc.) are intentionally omitted. Since neither schema setsadditionalProperties: false, those keys remain fully valid and functional — they are simply not schema-validated or rendered as form fields.Notes on typing
nullinvalues.yamlaccept"null"in their type so the shipped defaults pass Helm validation.hpaCPU/hpaMemoryare typed asstring|null(thehpa.yamltemplate compares them to""andnil, so an integer breaks rendering).patternregexes consistent with themariadbschema.required: ["name", "image"]; nestedrequiredarrays are scoped to their objects and only fire when those optional sections are populated.Verification
helm lintpasses for both chartshelm templaterenders both with defaultvalues.yamlhelm templaterenders both with every schema field set to a realistic value, and the values flow through to the manifests (Deployment/HPA/Ingress/PrometheusRule for service; CronJob/PrometheusRule for cron-job)serviceType/concurrencyPolicyenums, missing required fields)