Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/giantswarm/helm-values-gen
Helm plugin 'values-gen' generates the default values file based of values.schema.json
https://github.com/giantswarm/helm-values-gen
github-action helm helm-plugin helm-plugins plugin
Last synced: 4 months ago
JSON representation
Helm plugin 'values-gen' generates the default values file based of values.schema.json
- Host: GitHub
- URL: https://github.com/giantswarm/helm-values-gen
- Owner: giantswarm
- License: apache-2.0
- Created: 2023-02-14T10:53:50.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-26T12:26:14.000Z (4 months ago)
- Last Synced: 2024-08-26T14:42:58.781Z (4 months ago)
- Topics: github-action, helm, helm-plugin, helm-plugins, plugin
- Language: Go
- Homepage:
- Size: 178 KB
- Stars: 3
- Watchers: 5
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Codeowners: CODEOWNERS
- Security: SECURITY.md
Awesome Lists containing this project
README
# helm-values-gen
`helm-values-gen` generates a YAML payload that contains all default values in
a given JSON schema. This is useful when maintaining a helm project with a
`values.schema.json` that already contains the default values that are
expected in `values.yaml`.## Installation
Currently, `helm-values-gen` can be installed as Go binary.
In the future it will be (additionally) possible to install it as a helm plugin.```nohighlight
go install github.com/giantswarm/helm-values-gen@latest
```## Usage
```nohighlight
$ helm-values-gen values.schema.json -o values.yamlWrote default values to values.yaml
```Use `--help` to learn about more options.
## Details
As JSON schemas can be nested deeply, we need to define which default values
will be contained in the resulting payload.
The tool follows these steps:1. Start in the root of the schema
2. If there is a default value, add it to the payload.
3. Recurse into all properties.**Note**:
The tool does not recurse into the `items` keyword of an array.
To specify default values for an array you have to set a default on the level
of the array.Consider the following example:
values.schema.json
```json
{
"type": "object",
"properties": {
"addresses": {
"type": "array",
"items": {
"type": "object",
"properties": {
"city": {
"type": "string",
"default": "New York"
}
}
},
},
"lastName": {
"type": "string",
"default": "Doe"
}
}
}
```values.yaml
```yaml
lastName: Doe
```The default value `addresses[].city = "New York"` is not reflected in
`values.yaml`.To specify a default value for an array consider the following example:
```json
{
"type": "object",
"properties": {
"addresses": {
"type": "array",
"items": {
"type": "object"
"properties": {
"city": {
"type": "string",
"default": "New York"
}
}
},
"default": [
{
"city": "New York"
}
]
},
"lastName": {
"type": "string",
"default": "Doe"
}
}
}
```values.yaml
```yaml
addresses:
- city: New York
lastName: Doe
```## GitHub Action
An action to run `schemalint verify` on the `values.schema.json` in app repositories in provided in `actions/verify-helm-schema`.
**Example workflow**:
```yaml
name: JSON schema validation
on:
push: {}jobs:
generate:
name: Check that values.yaml is generated from values.schema.json with helm-values-gen
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3- name: Run helm-values-gen
id: run-helm-values-gen
uses: giantswarm/helm-values-gen/actions/ensure-generated@v1
```## Major Releases
This repository uses [floating tags](https://github.com/giantswarm/floating-tags-action).
Other repositories that use helm-values-gen point to major floating tag versions,
like `v1`. That means that all minor and patch releases will be automatically
rolled out to these repositories.
When doing a major release the following steps have to be completed:
1. Create a new major floating tag under "Actions -> Ensure major version tags -> Run Workflow"
2. Update all references to schemalint.
1. devctl: `pkg/gen/input/workflows/internal/file/cluster_app_schema_validation.yaml.template`