Giter Site home page Giter Site logo

losisin / helm-values-schema-json Goto Github PK

View Code? Open in Web Editor NEW
32.0 3.0 4.0 156 KB

Helm plugin for generating values.schema.json from multiple values files

License: MIT License

Shell 8.31% Go 85.66% Makefile 6.03%
helm-plugin json-schema json-schema-generator helm helm-chart helm-charts helm-plugins schema-json

helm-values-schema-json's People

Contributors

dependabot[bot] avatar ignite-ci avatar losisin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

hajowieland

helm-values-schema-json's Issues

pointers in values

Hi,

Can I set items in the array to a certain type, like string? I have a helm chart values where I need to set something like this (those should be the default values in the chart):

app: settings: writeNamespace: &writeNamespace app1 watchNamespaces: - *writeNamespace

And as a result of schema generation I get:

`
"writeNamespace": {
"type": [
"string"
]
}

"watchNamespaces": {
	"items": {
		"type": null
	},
	"type": "array"
},

`

It seems that the type is not detected. And this off course fails when I try to run helm template command. If I correct the type of the items manually, it works.

I went through the repo docs but I couldn't find the solution.

add default using comments

It could be also nice to have to be able to add a default annotation in the schema coming from the comment

Support for declaring items types in empty array

I dont seem to be able to figure out how properly declare that items within an array have a type unless my array object in values.yaml has an array with those objects declared. But I want the default to be [].

For example:

domains: [] 
# - domain.com
# - domain.co

results in domain: { type: array }
I want to be able to make this become domain: { type: array, items: { type: string }}

Allow adding additionalProperties: false to the generated Schema

Currently the generated JSON Schema does not take into account when values are set which are not defined a values.yaml.

In JSON schema, we can set additionalProperties: false to properties (see Documentation), which then causes e.g. helm lint to error when there are values set which are for example incorrectly indented.

This helps debugging wrongly indented values, which can be hard to spot or even cause other side effects like removing resources via gitOps (when pruning is enabled) if values are just missing some spaces.

Example:

values.yaml:

onevalue:
  secondvalue:
    test: 123

With the currently generated JSON Schema, the following option values would not cause any errors:

values-test.yaml:

onevalue:
  test: 123

Generated schema:

{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "properties": {
        "onevalue": {
            "properties": {
                "secondvalue": {
                    "properties": {
                        "test": {
                            "type": "integer"
                        }
                    },
                    "type": "object"
                }
            },
            "type": "object"
        }
    },
    "type": "object"
}

Running helm lint:

helm lint --strict . -f values-test.yaml
==> Linting .
[INFO] Chart.yaml: icon is recommended

1 chart(s) linted, 0 chart(s) failed

But when additionalProperties: false is added to all properties in the JSON schema like this:

{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "additionalProperties": false,
    "properties": {
        "onevalue": {
            "additionalProperties": false,
            "properties": {
                "secondvalue": {
                    "additionalProperties": false,
                    "properties": {
                        "test": {
                            "type": "integer"
                        }
                    },
                    "type": "object"
                }
            },
            "type": "object"
        }
    },
    "type": "object"
}

then running helm lint fails:

helm lint --strict . -f values-test.yaml
==> Linting .
[INFO] Chart.yaml: icon is recommended
[ERROR] values.yaml: - onevalue: Additional property test is not allowed

[ERROR] templates/: values don't meet the specifications of the schema(s) in the following chart(s):
test:
- onevalue: Additional property test is not allowed


Error: 1 chart(s) linted, 1 chart(s) failed

Allow to set type for optional values

Our use-case is as follows:
In the chart we have various optional values, e.g. defined with an empty value in the values.yaml:

# -- replica count
replicaCount:

In the Helm chart template:

  {{- if $values.replicaCount }}
  replicas: {{ $values.replicaCount }}
  {{- end }}

The requirement is to have the value listed in the values.yaml, so that we can document it with helm-docs, but we want the value to be optional and not set per default.

This now generates the following schema:

        "replicaCount": {
            "type": "null"
        }

This results in an Invalid type error.

Maybe it would be possible to specify the type as a comment on the property similar to the requirement in #21

Do you have any plans to implement something like this?

BTW: Nice plugin ๐Ÿ‘

Add option for title in schema comments

Adding the option to write a title can help with the generation of pretty looking forms from the schema.
Having it in the # schema comment section could help

required fields

Hi,

Thanks for this nice plugin. We started using it the other day for our internal Helm charts. Do you have any plans to implement required fields somehow like from comments/annotations or any other way?

Thanks,
Milos

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.