giantswarm / roadmap

Giant Swarm Product Roadmap
https://github.com/orgs/giantswarm/projects/273
Apache License 2.0
3 stars 0 forks source link

Generate `values.yaml` from `values.schema.json` #1983

Closed mogottsch closed 1 year ago

mogottsch commented 1 year ago

With https://github.com/giantswarm/roadmap/issues/1733 we want to add a lot more information to our values.schema.json files. Using helm schema-gen in its current state will overwrite/erase most schema information.

One solution to this worklow problem could be to turn it around: Generate values.yaml from values.schema.json. In theory, the schema could contain all information required.

Details:

Illustration

From

{
  "type": "object",
  "properties": {
    "myProperty": {
      "title": "Example property",
      "description": "Simply a string value.",
      "type": "string",
      "default": "default value"
    }
  }
}

make

# Example property
#
# Simply a string value.
myProperty: default value
mogottsch commented 1 year ago

I moved this from the Hackathon board to our board.

Notes from the meeting (marian & moritz):

In order to construct values.yaml we will traverse all properties in the values.schema.json. We won't traverse into the items of arrays, as we expect arrays to declare default items directly at the level of the array.

Comments in the values.yaml are not the priority, therefore if that is hard to accomplish we will leave it out.

The use-case of generating a default payload from a JSON schema seems to be very general. Therefore, we will check whether such a tool already exists.

mogottsch commented 1 year ago

I found no library that generates a payload from the defaults in a JSON schema.

There is a python library "jsonschema-default", however, it generates a whole sample paylaod, not just the defaults.

rjsf implements the logic of getting defaults from a form. As rjsf is intended for another purpose (or at least it has a much wider scope), I suggest to implement the default payload generation ourselves.

mogottsch commented 1 year ago

This is implemented in https://github.com/giantswarm/helm-values-gen.

Concerning the helm plugin part: Currently, there is no need to provide helm-values-gen as a helm plugin rather than a simple go CLI. Helm does not provide any possibilities to find "the" helm charts in a repository, nor does not help to provide a better update experience.