Coder Social home page Coder Social logo

giantswarm / helm-values-gen Goto Github PK

View Code? Open in Web Editor NEW
3.0 5.0 0.0 158 KB

Helm plugin 'values-gen' generates the default values file based of values.schema.json

License: Apache License 2.0

Makefile 30.30% Go 68.40% Shell 1.30%
helm helm-plugin helm-plugins plugin github-action

helm-values-gen's Introduction

helm-values-gen

helm-values-gen generates a YAML payload that contains all default values in a given JSON schema. This is useful when maintaining a helm project with a values.schema.json that already contains the default values that are expected in values.yaml.

Installation

Currently, helm-values-gen can be installed as Go binary. In the future it will be (additionally) possible to install it as a helm plugin.

go install github.com/giantswarm/helm-values-gen@latest

Usage

$ helm-values-gen values.schema.json -o values.yaml

Wrote default values to values.yaml

Use --help to learn about more options.

Details

As JSON schemas can be nested deeply, we need to define which default values will be contained in the resulting payload. The tool follows these steps:

  1. Start in the root of the schema
  2. If there is a default value, add it to the payload.
  3. Recurse into all properties.

Note: The tool does not recurse into the items keyword of an array. To specify default values for an array you have to set a default on the level of the array.

Consider the following example:

values.schema.json

{
  "type": "object",
  "properties": {
    "addresses": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "city": {
            "type": "string",
            "default": "New York"
          }
        }
      },
    },
    "lastName": {
      "type": "string",
      "default": "Doe"
    }
  }
}

values.yaml

lastName: Doe

The default value addresses[].city = "New York" is not reflected in values.yaml.

To specify a default value for an array consider the following example:

{
  "type": "object",
  "properties": {
    "addresses": {
      "type": "array",
      "items": {
        "type": "object"
        "properties": {
          "city": {
            "type": "string",
            "default": "New York"
          }
        }
      },
      "default": [
        {
          "city": "New York"
        }
      ]
    },
    "lastName": {
      "type": "string",
      "default": "Doe"
    }
  }
}

values.yaml

addresses:
  - city: New York
lastName: Doe

GitHub Action

An action to run schemalint verify on the values.schema.json in app repositories in provided in actions/verify-helm-schema.

Example workflow:

name: JSON schema validation
on:
  push: {}

jobs:
  generate:
    name: Check that values.yaml is generated from values.schema.json with helm-values-gen
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v3

      - name: Run helm-values-gen
        id: run-helm-values-gen
        uses: giantswarm/helm-values-gen/actions/ensure-generated@v1

Major Releases

This repository uses floating tags. Other repositories that use helm-values-gen point to major floating tag versions, like v1. That means that all minor and patch releases will be automatically rolled out to these repositories. When doing a major release the following steps have to be completed:

  1. Create a new major floating tag under "Actions -> Ensure major version tags -> Run Workflow"
  2. Update all references to schemalint.
    1. devctl: pkg/gen/input/workflows/internal/file/cluster_app_schema_validation.yaml.template

helm-values-gen's People

Contributors

andidog avatar architectbot avatar github-actions[bot] avatar marians avatar mogottsch avatar renovate[bot] avatar taylorbot avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

helm-values-gen's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Repository problems

These problems occurred while renovating this repository. View logs.

  • WARN: Use matchDepNames instead of matchPackageNames

This repository currently has no open or pending branches.

Detected dependencies

circleci
.circleci/config.yml
  • architect 5.1.1
github-actions
.github/workflows/update_action.yaml
  • actions/checkout v4
  • actions/setup-node v4
  • actions/checkout v4
  • mikefarah/yq v4.43.1@c35ec752e38ea0c096d3c44e13cfc0797ac394d8
actions/ensure-generated/action.yml
  • giantswarm/install-binary-action v2.0.0
gomod
go.mod
  • go 1.20
  • github.com/giantswarm/microerror v0.4.1
  • github.com/google/go-cmp v0.6.0
  • github.com/santhosh-tekuri/jsonschema/v5 v5.3.1
  • github.com/spf13/cobra v1.8.0
  • gopkg.in/yaml.v3 v3.0.1
  • sigs.k8s.io/yaml v1.4.0
npm
.github/find_release_pr/package.json
  • @actions/core ^1.10.0
  • @actions/exec ^1.1.1

  • Check this box to trigger a request for Renovate to run again on this repository

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.