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

Feature/markers #9

Merged
merged 13 commits into from
Nov 17, 2024
Merged

Feature/markers #9

merged 13 commits into from
Nov 17, 2024

Conversation

SQLJames
Copy link
Contributor

added new schemagen tag support for headcomments of yaml file
this is gated in the generate command by a feature flag that you will need to enable by passing in --schemagen
The idea behind this initial pass is that you will be able to modify the types of your yaml through the yaml comments.

so for example:

autoscaling:
  enabled: false
  minReplicas: 1 

  # +schemagen:type:number
  maxReplicas: 100
  targetCPUUtilizationPercentage: 80
  # targetMemoryUtilizationPercentage: 80

Will allow you to modify the maxReplicas to become a number type when by default it would have been an integer.

here is the difference in the output
bin/schema-gen generate ./testdata/values.yaml --schemagen --destination json.schema

{
    "$schema": "http://json-schema.org/schema#",
    "type": "object",
    "properties": {
        "autoscaling": {
            "type": "object",
            "properties": {
                "enabled": {
                    "type": "boolean"
                },
                "maxReplicas": {
                    "type": "number"
                },
                "minReplicas": {
                    "type": "integer"
                },
                "targetCPUUtilizationPercentage": {
                    "type": "integer"
                }
            }
        }
    }
}

bin/schema-gen -l debug generate ./testdata/demo.yaml --destination json.schema

{
    "$schema": "http://json-schema.org/schema#",
    "type": "object",
    "properties": {
        "autoscaling": {
            "type": "object",
            "properties": {
                "enabled": {
                    "type": "boolean"
                },
                "maxReplicas": {
                    "type": "integer"
                },
                "minReplicas": {
                    "type": "integer"
                },
                "targetCPUUtilizationPercentage": {
                    "type": "integer"
                }
            }
        }
    }
}

As part of this effort I also added global logging to allow us to gather information by just passing context. The new flag allows you to specify the log level for the zap logger, so most of the troubleshooting can be done with -l debug
Here is the associated help file for this command change

Generates a JSON schema from the provided Helm values.yaml file.

Usage:
  helm generate <values-yaml-file> [flags]

Flags:
      --destination string   Sets the default output location for the generated schema file
  -h, --help                 help for generate
      --schemagen            Allows the user to use +schemagen comments to modify the output

Global Flags:
  -l, --log-level string   Set the logging level (debug, info, warn, error, dpanic, panic, fatal) (default "info")

@SQLJames SQLJames merged commit 1b926f6 into main Nov 17, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant