npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

helm-parser

v1.1.4

Published

[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=rounded-square)](https://github.com/prettier/prettier) [![CI](https://github.com/alexbechmann/helm-parser/actions/workflows/ci.yml/badge.svg?branch=main)](https://g

Downloads

1,107

Readme

Helm Parser

code style: prettier CI npm

_   _      _             ____
| | | | ___| |_ __ ___   |  _ \ __ _ _ __ ___  ___ _ __
| |_| |/ _ \ | '_ ` _ \  | |_) / _` | '__/ __|/ _ \ '__|
|  _  |  __/ | | | | | | |  __/ (_| | |  \__ \  __/ |
|_| |_|\___|_|_| |_| |_| |_|   \__,_|_|  |___/\___|_|

Template a helm chart with the Helm CLI and load the manifests into an array of JavaScript objects. Mainly intended for use within a test suite.

Helm charts can get very complicated at scale, with an infinite combination of values that can be passed to the chart by consumers. With Helm Parser, you can write comprehensive tests for your chart, using your favourite JS testing framework.

Features

  • [x] Loads the chart's manifests into an array of JavaScript objects
  • [x] Typed manifests
  • [x] You can provide a type your values (or autogenerate one from a JSON schema)
  • [x] Helper functions to easily pick out a specific manifest
  • [x] Usage with any JS test framework

Prerequisites

  • Helm CLI installed on system

Installation

npm install helm-parser

Usage

import path from "path";
import { HelmParser } from "helm-parser";

const helmParser = new HelmParser({
  chartPath: path.resolve(__dirname, "./path-to/my-chart-dir");
});

const result = helmParser.template({
  chartPath,
  namespace: "my-namespace",
  releaseName: "my-release",
  values: {
    replicaCount: 3,
  },
});

const deployments = result.manifests.filter((manifest) => manifest.kind === "Deployment");

Helper functions

const deployments = result.getDeployments();
const myDeployment = result.getDeployment("my-deployment");

const services = result.getServices();
const myService = result.getService("my-service");

const ingresses = result.getIngresses();
const myIngress = result.getIngress("my-ingress");

Usage for testing

Optionally add a JSON Schema to your chart

You should place this alongside your Chart.yaml file.

This is a helm feature which will validate parameters, as well as allow you to generate a typescript definition for your values.

https://helm.sh/docs/topics/charts/#schema-files

values.schema.json

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "additionalProperties": true,
  "properties": {
    "replicaCount": {
      "type": "number"
    },
    "something": {
      "type": "string",
      "enum": ["a", "b", "c"]
    }
  }
}

Bootstrap project

npx create-helm-tests my-tests --chart-path ./path-to/my-chart-dir

Write tests

test/main.test.ts

test("can set replicas to 3", () => {
  const result = helmParser.template({
    namespace: "my-namespace",
    releaseName: "my-release",
    values: {
      replicaCount: 3,
    },
  });
  const deployment = result.getDeployment("my-deployment");
  expect(deployment.spec.replicas).to.equal(3);
});