losisin / helm-values-schema-json

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

multiple types not inferred when multiple values files are used #88

Closed cornfeedhobo closed 1 month ago

cornfeedhobo commented 2 months ago

If two values files are passed with the same block, but with different types:

resources:
  requests:
    cpu: "100m"
resources:
  requests:
    cpu: 100

The resulting schema type should become an array:

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "properties": {
    "resources": {
      "properties": {
        "cpu": {
          "type": ["string", "number"]
        }
      },
      "type": "object"
    }
  }
}
losisin commented 2 months ago

@cornfeedhobo the plugin behaves the same way as helm would when passing multiple values files, which means the latter file will take precedence and serve as override. Adding comment in latter values file will generate the desired schema:

resources:
  requests:
    cpu: 100 # @schema type:[number,string]

I'm going to update documentation to make it more clear for other users too. Thank you for the feedback!