1.2.4 • Published 6 months ago

@socialgouv/helm-schema v1.2.4

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
6 months ago

@socialgouv/helm-schema npm (scoped)

JSON Schema generator for your HELM charts.

Demo : https://socialgouv.github.io/helm-schema

Usage

Example values.yaml, following JSDoc standards

# @param {object} smtp Your SMTP setup
smtp:
  # @param {string} host SMTP hostname
  host:
  # @param {number} [port] SMTP port
  port: 587

# Setup your securityContext to reduce security risks, see https://kubernetes.io/docs/tasks/configure-pod-container/security-context/
# @param {https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.24.0/_definitions.json#/definitions/io.k8s.api.core.v1.PodSecurityContext} [securityContext]
securityContext:

To generate a JSON schema from your values.yaml :

npx @socialgouv/helm-schema -f values.yaml

Or via TS :

import { toJsonSchema } from "@socialgouv/helm-schema";

import yaml from "./values.yaml";

const schema = toJsonSchema(yaml);

You get such JSON schema in result :

{
  "type": "object",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "required": ["smtp"],
  "properties": {
    "smtp": {
      "type": "object",
      "title": "Your SMTP setup",
      "required": ["host"],
      "properties": {
        "host": {
          "type": "string",
          "title": "SMTP hostname"
        },
        "port": {
          "type": "number",
          "title": "SMTP port",
          "default": "587"
        }
      }
    },
    "securityContext": {
      "$ref": "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.24.0/_definitions.json#/definitions/io.k8s.api.core.v1.PodSecurityContext",
      "description": "Setup your securityContext to reduce security risks, see https://kubernetes.io/docs/tasks/configure-pod-container/security-context/"
    }
  }
}

This schema can then be used with your favorite editor for HELM values validation.

⚠️ Be sure to add an $id to the schema if its meant to be referenced from other schemas

Dev

update snapshots : yarn snapshots

Todo

  • multiline comments
  • sections
  • infer types from default values
  • handle arrays
1.2.4

6 months ago

1.2.3

8 months ago

1.2.2

8 months ago

1.2.1

8 months ago

1.2.0

8 months ago

1.1.1

8 months ago

1.1.0

8 months ago

1.0.6

9 months ago

1.0.5

9 months ago

1.0.4

9 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago