|
| 1 | +--- |
| 2 | +hip: 0027 |
| 3 | +title: "Generate values.schema.json from values.yaml" |
| 4 | +authors: [ "@salvorusso" ] |
| 5 | +created: "2025-09-22" |
| 6 | +type: "feature" |
| 7 | +status: "draft" |
| 8 | +--- |
| 9 | + |
| 10 | +## Abstract |
| 11 | + |
| 12 | +This proposal introduces a new Helm CLI subcommand to automatically generate a draft `values.schema.json` file from a chart’s `values.yaml`. The goal is to improve the developer experience for chart maintainers, lower the barrier for schema adoption, and encourage more consistent use of schema validation in Helm charts. |
| 13 | + |
| 14 | +## Motivation |
| 15 | + |
| 16 | +Helm supports validating values against a `values.schema.json`, but chart authors must currently write this file manually. |
| 17 | +While external tools exist (e.g., [helm-schema-gen](https://github.com/karuppiah7890/helm-schema-gen)), this functionality feels like a natural fit within Helm itself. |
| 18 | + |
| 19 | +Providing a first-class command inside Helm: |
| 20 | + |
| 21 | +* **Reduces friction**: Chart maintainers can bootstrap a schema instantly. |
| 22 | +* **Encourages adoption**: More charts will ship with `values.schema.json`. |
| 23 | +* **Unifies tooling**: Avoids reliance on third-party scripts for a common workflow. |
| 24 | + |
| 25 | +## Rationale |
| 26 | + |
| 27 | +The proposed feature is additive, has no impact on existing commands, and aligns with Helm’s mission of simplifying chart authoring. By starting with a basic generator that infers types and structures, Helm provides a helpful baseline while leaving fine-grained constraints (e.g., `required`, `enum`) to the chart author. |
| 28 | + |
| 29 | +## Specification |
| 30 | + |
| 31 | +### New Command |
| 32 | + |
| 33 | +```bash |
| 34 | +helm schema generate values.yaml [flags] |
| 35 | +``` |
| 36 | + |
| 37 | +### Behavior |
| 38 | + |
| 39 | +* Parses `values.yaml`. |
| 40 | +* Infers JSON Schema types (`string`, `number`, `boolean`, `object`, `array`). |
| 41 | +* Outputs a draft schema to stdout or a file. |
| 42 | +* Optional: include YAML comments as `"description"`. |
| 43 | + |
| 44 | +### Example |
| 45 | + |
| 46 | +Input (`values.yaml`): |
| 47 | + |
| 48 | +```yaml |
| 49 | +replicaCount: 3 |
| 50 | +image: |
| 51 | + repository: nginx |
| 52 | + tag: "1.25.0" |
| 53 | + pullPolicy: IfNotPresent |
| 54 | +service: |
| 55 | + enabled: true |
| 56 | + type: ClusterIP |
| 57 | + port: 80 |
| 58 | +``` |
| 59 | +
|
| 60 | +Output (`values.schema.json`): |
| 61 | + |
| 62 | +```json |
| 63 | +{ |
| 64 | + "$schema": "http://json-schema.org/draft-07/schema#", |
| 65 | + "type": "object", |
| 66 | + "properties": { |
| 67 | + "replicaCount": { "type": "integer" }, |
| 68 | + "image": { |
| 69 | + "type": "object", |
| 70 | + "properties": { |
| 71 | + "repository": { "type": "string" }, |
| 72 | + "tag": { "type": "string" }, |
| 73 | + "pullPolicy": { "type": "string" } |
| 74 | + } |
| 75 | + }, |
| 76 | + "service": { |
| 77 | + "type": "object", |
| 78 | + "properties": { |
| 79 | + "enabled": { "type": "boolean" }, |
| 80 | + "type": { "type": "string" }, |
| 81 | + "port": { "type": "integer" } |
| 82 | + } |
| 83 | + } |
| 84 | + } |
| 85 | +} |
| 86 | +``` |
| 87 | + |
| 88 | +## Backward Compatibility |
| 89 | + |
| 90 | +* No breaking changes. |
| 91 | +* Feature is optional and additive. |
| 92 | + |
| 93 | +## Security implications |
| 94 | +* No security impact. |
| 95 | +* Reads YAML and writes schema only; does not interact with cluster or secrets. |
| 96 | + |
| 97 | +## How to teach this |
| 98 | +* Update Helm documentation with examples. |
| 99 | +* Blog post announcing the feature. |
| 100 | + |
| 101 | +## Reference implementation |
| 102 | + |
| 103 | +N/A - to be developed if the proposal is accepted. |
| 104 | + |
| 105 | +## Rejected ideas |
| 106 | + |
| 107 | +## Open issues |
| 108 | +* Handling complex types (e.g., mixed arrays). |
| 109 | +* Deciding on defaults for ambiguous types. |
| 110 | + |
| 111 | +## References |
| 112 | + |
| 113 | +* [Helm values.schema.json docs](https://helm.sh/docs/topics/charts/#schema-files) |
| 114 | +* [helm-schema-gen](https://github.com/karuppiah7890/helm-schema-gen) |
| 115 | +* [JSON Schema draft-07](https://json-schema.org/draft-07/schema) |
| 116 | +* [HIP 1: Helm Improvement Proposal Process](https://github.com/helm/community/blob/main/hips/hip-0001.md) |
0 commit comments