Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HIP for outputting chart JSON schemas #200

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions hips/hip-9999.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
---
hip: "9999"
title: "Output Helm Chart Schemas"
authors: [ "Remco Haszing <remcohaszing@gmail.com>" ]
created: "2021-07-14"
type: "feature"
status: "draft"
---

## Abstract

Helm supports JSON schema validation to validate `values.yaml`.
It would be nice if JSON schema validation is also possible by editors of `values.yaml` files.
It would be nice if JSON schemas can be referenced by dependant Helm chart JSON schemas.
Both will be possible if the JSON schemas are served on separate URLs.

## Motivation

For Helm users it would be nice if they can reference JSON schemas from a Helm chart.

If a Helm chart depends on another Helm chart, its JSON schema can reference the original JSON schema like so:

```json
{
"properties": {
"my-chart": {
"$ref": "https://charts.example/my-chart-1.2.3.schema.json"
}
}
}
```

If a user wants to enable JSON schema validation and completion for `values.yaml` when using [`yaml-language-server`](https://github.com/redhat-developer/yaml-language-server), this can be accomplished by a modeline:

```yaml
# yaml-language-server: $schema=https://charts.example/my-chart-1.2.3.schema.json
```

## Rationale

By outputting the JSON schema next to the packaged Helm chart, Helm determines the standard output location.
Chart publishers could copy their JSON schema manually, but this isn’t standardized in any way.
If Helm determines the standard output location of such files, chart publishers are likely to use this.
Helm already outputs an additional file for signed charts. This proposal is consistent with that behaviour.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This implies that chart publishers will publish schema files, but it does not explain how charts stored in OCI registries would make schemata available. While OCI is considered an experimental feature, because it is part of Helm's core we would need to introduce a solution for that registry as well as for a regular Helm chart repo.


## Specification

If a Helm chart containing a `values.schema.json` is built using `helm package`, Helm will output the contents of `values.schema.jsob` alongside of it.
remcohaszing marked this conversation as resolved.
Show resolved Hide resolved
The file structure of the output will look like this:

```
├─ my-chart-1.2.3.json.schema
├─ my-chart-1.2.3.tgz
└─ my-chart-1.2.3.tgz.prov
```

## Backwards Compatibility

Outputting an additional file is backwards compatible.
If a chart published previously assumed a single output file, as was the case for unsigned charts, the JSON schema file is ignored.

## Security implications

This HIP has no security implications.

## How to teach this

The documentation should be updated to reflect this change.
Users should be recommended to publish the JSON file as well, thus not treating the output directory as the output, not just the Helm chart package.

## Reference Implementation

## Rejected ideas

N/A

## Open issues

https://github.com/helm/helm/issues/9920

## References

- [`yaml-language-server`](https://github.com/redhat-developer/yaml-language-server)
- `yaml-language-server` [modeline](https://github.com/redhat-developer/yaml-language-server#using-inlined-schema)
- [JSON schema $ref](https://json-schema.org/understanding-json-schema/structuring.html#ref)