Giter Site home page Giter Site logo

banshee86vr / helm-schema Goto Github PK

View Code? Open in Web Editor NEW

This project forked from socialgouv/helm-schema

0.0 0.0 0.0 1.8 MB

JSON Schema generator for your HELM charts

Home Page: https://banshee86vr.github.io/helm-schema/

JavaScript 4.60% TypeScript 95.40%

helm-schema's Introduction

@bertelli.luca/helm-schema npm (scoped) Publish demo Tests n publish

JSON Schema generator for your HELM charts.

Project forked from: https://github.com/SocialGouv/helm-schema

Demo: https://banshee86vr.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

# @param {enum{IfNotPresent,Always,Never}} pullPolicy Specifies whether a container image should be created
pullPolicy: IfNotPresent
# @param {pattern{^.*$}} name Application name validated by a pattern
name: JSONSchemaGenerator
# @param {integer{min=0,max=5}} replicaCount Number of possible replica with a fixed range
replicaCount: 3
# @param {string{minLength=10,maxLength=15}} username Username with limited length range
username: banshee86vr
# @param {string[CreateNamespace=true,Prune=false,SkipDryRunOnMissingResource=true]} [syncOptions] Options allow you to specify whole app sync-options
syncOptions: []

# 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 @bertelli.luca/helm-schema -f values.yaml

Or via TS :

import { toJsonSchema } from "@bertelli.luca/helm-schema";

import yaml from "./values.yaml";

const schema = toJsonSchema(yaml);

You get such JSON schema in result :

{
  "type": "object",
  "$schema": "http://json-schema.org/draft-07/schema",
  "required": ["smtp", "pullPolicy", "name", "replicaCount", "username"],
  "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"
        }
      }
    },
    "pullPolicy": {
      "type": ["string", "boolean", "number", "object", "array"],
      "enum": ["IfNotPresent", "Always", "Never"],
      "title": "Specifies whether a container image should be created",
      "default": "IfNotPresent"
    },
    "name": {
      "type": "string",
      "pattern": "^.*$",
      "title": "Application name validated by a pattern",
      "default": "JSONSchemaGenerator"
    },
    "replicaCount": {
      "type": "integer",
      "minimum": 0,
      "maximum": 5,
      "title": "Number of possible replica with a fixed range",
      "default": "3"
    },
    "username": {
      "type": "string",
      "minLength": 10,
      "maxLength": 15,
      "title": "Username with limited length range",
      "default": "banshee86vr"
    },
    "syncOptions": {
      "type": "array",
      "default": [
        "CreateNamespace=true",
        "Prune=false",
        "SkipDryRunOnMissingResource=true"
      ],
      "title": "Options allow you to specify whole app sync-options",
      "items": {
        "type": ["string"]
      }
    },
    "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

helm-schema's People

Contributors

socialgroovybot avatar banshee86vr avatar semantic-release-bot avatar renovate[bot] avatar

helm-schema's Issues

Abiity to handle default for array of type string

I would like to use a jsdoc comment to generate the following json schema:

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "favoriteColors": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "default": ["blue", "green", "red"]
    }
  }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.