losisin / helm-values-schema-json

Helm plugin for generating values.schema.json from multiple values files
MIT License
75 stars 11 forks source link

Allow schema ref definition for keys #83

Closed Persi closed 2 months ago

Persi commented 2 months ago

We are using some base helm charts which provide defaults for e.g. spring boot deployments. These charts provide a schema.json and are used as subcharts in our real world applications.

Some of the properties of the subcharts need to be overridden by the concrete chart, by using the name of the subchart as root key in the values.yaml.

If I got JSON schema reference right, it is possible to define the supported properties of a key via $ref to another json schema. It would be cool, if I could add a schema ref definition to the subcharts schema in my values.yaml e.g. like this:

subchart: # @schema $ref: https://schema/url/...
  key: 

This definition should lead to the following output on schema generation of my values schema:

{
...
  "properties": {
      "subchart": {
        "$ref": "https://schema/url/..."
      }
  }
...

Currently the generator is just taking all of the present keys beneath subchart without reference to the subcharts schema def.

losisin commented 2 months ago

@Persi thank you for the suggestion. I'll add support for $ref including cli flag schemaRoot.ref. Keep in mind that properties where you would use it in comment will override/extend and take precedence over the external schema. For objects you can also use it in combination with skipProperties: true so that properties won't be generated at all by the plugin. Hope this helps

Persi commented 2 months ago

Thank you for the fast implementation. I'll give it a look with the next release of your plugin.

Persi commented 2 months ago

Works as expected with release 1.5.3. Thank you very much! :)