@senchou/core
TypeScript icon, indicating that this package has built-in type declarations

1.2.3 • Public • Published

@senchou/core

Generate TypeScript for Kubernetes resources.

Installation

# Using npm.
npm install @senchou/core

# Using yarn.
yarn add @senchou/core

Usage

Import

Imports fetch manifests from sources, returning a JSON Schema, CustomResourceDefinitions, or JSON-formatted manifests.

Kubernetes

To import a Kubernetes release's schema, see the following example.

import core from "@senchou/core";

const schema = await core.import.kubernetes();

To import a specific release, specify the version number.

import core from "@senchou/core";

const schema = await core.import.kubernetes("1.20.0");

CustomResourceDefinition

CustomResourceDefinitions can be imported from supported sources.

GitHub

Importing CustomResourceDefinitions from GitHub is supported via doc.crds.dev. To import CRDs from GitHub, see the following example.

import core from "@senchou/core";

const crds = await core.import.github("traefik/traefik-helm-chart");
Helm

Helm Charts can be imported if Helm is installed. See the following example.

import core from "@senchou/core";

const manifests = await core.import.helm({
	name: "my-traefik-deployment",
	chart: "traefik/traefik",
});

To supply custom values for a chart, see the following example.

import core from "@senchou/core";

const manifests = await core.import.helm({
	name: "my-traefik-deployment",
	chart: "traefik/traefik",
	values: {
		// Any values for your chart can be set here.
		ingressRoute: {
			dashboard: {
				enabled: false,
			},
		},
	},
});

Custom arguments can be passed to the Helm command line if extra customization is necessary.

import core from "@senchou/core";

const manifests = await core.import.helm({
	name: "my-traefik-deployment",
	chart: "traefik/traefik",
	args: ["--my-arg", "--my-other-arg"],
});

Generate

TypeScript code can be generated from imported Kubernetes JSON Schemas or CustomResourceDefinitions.

Kubernetes

To generate types for a Kubernetes release, see the following example.

import core from "@senchou/core";

const schema = await core.import.kubernetes();

const code = core.generate.kubernetes(schema);

CustomResourceDefinitions

To generate types for CustomResourceDefinitions, see the following example.

import core from "@senchou/core";

// CRDs from any source can be used.
const crds = await core.import.github("traefik/traefik-helm-chart");

const code = core.generate.crd(crds);

Utility

A helper and type exists to assert that an object is a CustomResourceDefinition.

import { isCRD, CustomResourceDefinition } from "@senchou/core";

const invalid = {};

isCRD(invalid); // false

const valid = {
	kind: "CustomResourceDefinition",
};

if (isCRD(valid)) {
	// valid is CustomResourceDefinition
}

const crd: CustomResourceDefinition = {
	/* ... */
};

Package Sidebar

Install

npm i @senchou/core

Weekly Downloads

3

Version

1.2.3

License

Apache-2.0

Unpacked Size

813 kB

Total Files

31

Last publish

Collaborators

  • jakehamilton