# Subcharts and dependencies

`helm-schema` analyzes a chart together with the dependencies it vendors, so the schema covers the
values its subcharts read too.

## Discovery

`helm-schema` reads `Chart.yaml`, or `Chart.template.yaml`, and the dependencies under `charts/`,
both as directories and as `.tgz` or `.tar.gz` archives. It analyzes each dependency's templates,
and the values a dependency reads appear in the schema under its key.

## Composed values and `global`

The values are composed as Helm composes them, from:

- the chart's own `values.yaml`;
- each subchart's defaults, under its dependency key;
- each subchart's `global` values, merged into the top-level `global`.

So a value a subchart reads from `.Values.global` and one the chart sets under the subchart's key
both land where the schema expects them.

`global` is allowed at the values root and at the root of every dependency, under its alias however
deeply nested: Helm accepts a `global` of any shape there, and copies it into each dependency before
it checks that dependency's own schema.

To analyze only the chart's own defaults and leave out those of the subcharts:

```sh
helm-schema ./mychart --no-subchart-values
```

## Library charts

A library chart (`type: library`) has no values of its own: its helpers run with the values of the
chart that includes them. `helm-schema` follows those `include` and `template` calls, so the values
a library helper reads appear under the chart that uses it.

- **Only the helpers you use count.** If a library defines ten helpers and your chart includes one,
  only that one's values appear in your schema.
- **Chains are followed.** When an included helper includes another, the values read at the end of
  the chain still land under your chart.

The same goes for the types and `default` fallbacks that
[`--infer-required`](https://romnn.github.io/helm-schema/docs/guide/values-and-defaults/#required-fields) reads, so a value required
through a library helper is required in the right chart.
