How it works
On this page
This page explains where each part of a generated schema comes from, so you can predict it and tell
a real problem from a deliberate choice. Using helm-schema does not require it.
Why not read values.yaml#
A chart’s values.yaml says what each value is set to, never what it may be:
service:
port: 80 # an integer, or would "http" work too?
replicas: 1 # a number, or could "1" pass?
ingress:
enabled: false # a boolean, or any value that is empty or not?The answers are in the templates. values.yaml also cannot show a value the templates read but
the file never sets, or tell an object from a map that happens to be empty.
Three signals#
For every value, helm-schema combines:
- How the templates use it. The resource field it renders into, and the
if,with,range,default,eq,notandoraround it. - The composed defaults. The chart’s
values.yaml, each subchart’s defaults under its key, andglobal, merged the way Helm merges them. - What Kubernetes expects there. Once a value is traced to a resource field, its type and description come from the Kubernetes or CRD schema of that field.
The result is one Draft-07 schema for the values object.
What that catches#
- Values without a default. A value the templates read appears in the schema even when
values.yamldoes not set it. - Real types. A port is an integer because the Service field it lands in is one, not because
80looks like a number. - Conditions. A value only used inside
{{ if .Values.x.enabled }}is only checked when that condition holds, as the template only renders it then. - Whole subtrees. A block poured into a typed field with
toYamlgets the full shape Kubernetes expects there, not only the keys the defaults set. - Misspelled keys. The values root is closed, so a key that no template reads is reported.
Recovered constraints and authoring assertions#
A schema holds two kinds of constraint:
- Recovered constraints follow from what the chart does. A value a template passes to
trunc, ranges over, or renders into a typed Kubernetes field is rejected when Helm would fail or render an invalid resource with it. - Authoring assertions follow from how the chart is written. The closed root reports a key no
template reads, and a declared default asserts its type, so
replicas: "3"is reported when the chart shipsreplicas: 1.
Helm can render values that an authoring assertion rejects; the assertions are there to catch
mistakes in values files. --open-root and --declared-types annotate turn them off, as
Values and defaults
describes.
It does not guess#
- An ambiguous value stays open. A value that can be several things stays a union, or stays unconstrained, rather than taking the type that looks most likely.
- A gap is reported. A value behind a computed key, or a resource whose
apiVersioncannot be pinned, is reported as a diagnostic on standard error. A schema override fills such a gap by hand.
Two guarantees#
- A shipped
values.schema.jsonis never read. A schema that the chart or a dependency already ships may be stale or written for another purpose, so the schema always comes from the chart’s templates and values.--override-schemaadds your own assertions on purpose. - The output is deterministic. The same chart, options and upstream schemas give the same bytes, so the file diffs cleanly and is safe to check in CI.