-
Notifications
You must be signed in to change notification settings - Fork 177
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
remcohaszing
wants to merge
2
commits into
helm:main
Choose a base branch
from
remcohaszing:output-helm-chart-schemas
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
||
## Specification | ||
|
||
If a Helm chart containing a `values.schema.json` is built using `helm package`, Helm will output the contents of `values.schema.json` alongside of it. | ||
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) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.