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 documentation #2

Merged
merged 7 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
32 changes: 32 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: ci
on:
pull_request:
branches:
- master
jobs:
test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
env:
VERBOSE: 1
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.20'
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
args: --timeout 5m0s
- name: Run fmt
run: go fmt ./...
- name: Run vet
run: go vet ./...
- name: Run tests
run: go test -v ./...
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @losisin
136 changes: 136 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# helm values schema json plugin

Helm plugin for generating `values.schema.json` from single or multiple values files. Works only with Helm3 charts.

## Install

```bash
$ helm plugin install https://github.com/losisin/helm-values-schema-json.git
Installed plugin: schema
```

## Features

- Add multiple values files and merge them together - required
- Save output with custom name and location - default is values.schema.json in current working directory
- Change schema draft version - default is draft 2020-12

## Usage

```bash
$ helm schema -help
usage: helm schema [-input STR] [-draft INT] [-output STR]
-draft int
Draft version (4, 6, 7, 2019, or 2020) (default 2020)
-input value
Multiple yamlFiles as inputs (comma-separated)
-output string
Output file path (default "values.schema.json")
```

### Basic

In most cases you will want to run the plugin with default options:

```bash
$ helm schema -input values.yaml
```

This will read `values.yaml`, set draft version to `2020-12` and save outpout to `values.schema.json`.

### Extended

Merge multiple values files, set json-schema draft version explicitly and save output to `my.schema.json`:

`values_1.yaml`

```yaml
nodeSelector:
kubernetes.io/hostname: ""
dummyList:
- "a"
- "b"
- "c"
key1: "asd"
key2: 42
key3: {}
key4: []
```

`custom/path/values_2.yaml`

```yaml
nodeSelector:
kubernetes.io/hostname: "node1"
deep:
deep1:
deep2:
deep3:
deep4: "asdf"
```

Run the following command to merge the yaml files and output json schema:

```bash
$ helm schema -input values_1.yaml,custom/path/values_2.yaml -draft 2020 -output my.schema.json
```

Output will be something like this:

```json
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"deep": {
"type": "object",
"properties": {
"deep1": {
"type": "object",
"properties": {
"deep2": {
"type": "object",
"properties": {
"deep3": {
"type": "object",
"properties": {
"deep4": {
"type": "string"
}
}
}
}
}
}
}
}
},
"dummyList": {
"type": "array",
"items": {
"type": "string"
}
},
"key1": {
"type": "string"
},
"key2": {
"type": "integer"
},
"key3": {
"type": "object"
},
"key4": {
"type": "array"
},
"nodeSelector": {
"type": "object",
"properties": {
"kubernetes.io/hostname": {
"type": "string"
}
}
}
}
}
```