render

package
v0.0.0-...-84176c5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package render runs `helm template` over a packaged chart and returns the objects of the render, for a chart check written in Go: one that compares what a chart renders with a Go constant, which a pattern in a BUILD file cannot do (//bazel/helm/meshnames).

Nothing here prints a render: with default values the aether chart generates the webhook's private key at render time (#1382). When helm fails, only its exit status is returned: nothing it wrote, on either stream. Helm can put manifest text on stderr (a YAML parse error quotes the document), and the pattern rules pass it through a fail-closed mask for that reason (render_lib.sh, show_helm_failure). This package has no mask, so it shows none of it. A document that does not parse is reported without its text.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Helm

type Helm struct {
	Binary  string
	Plugins string
}

Helm is the toolchain's helm: the binary and its plugins directory.

func (Helm) Template

func (h Helm) Template(chart, scratch string, opts ...string) ([]Object, error)

Template runs `helm template release-name <chart> <opts>` and returns the objects of the render, in the order helm printed them. scratch is a directory helm may write to: it keeps its caches, repository list and registry credentials under $HOME, and a sandbox has no writable home.

type Meta

type Meta struct {
	Name        string            `json:"name"`
	Namespace   string            `json:"namespace"`
	Labels      map[string]string `json:"labels"`
	Annotations map[string]string `json:"annotations"`
}

Meta is the part of an object's (or a pod template's) metadata a chart check compares.

type Object

type Object struct {
	APIVersion string       `json:"apiVersion"`
	Kind       string       `json:"kind"`
	Metadata   Meta         `json:"metadata"`
	Template   *PodTemplate `json:"-"`
}

Object is one document of a render. Template is nil for an object that has no pod template.

func Parse

func Parse(render string) ([]Object, error)

Parse splits a multi-document render into its objects. A document with no `kind` (an empty one, or only comments) is skipped.

func Workloads

func Workloads(objects []Object) []Object

Workloads returns the objects that have a pod template.

func (Object) ID

func (o Object) ID() string

ID is the object's "<Kind>/<name>".

type PodTemplate

type PodTemplate struct {
	Metadata Meta `json:"metadata"`
	Spec     struct {
		// Containers is what makes a `template` a pod template: see
		// podTemplate.
		Containers []struct {
			Name string `json:"name"`
		} `json:"containers"`
		Volumes []Volume `json:"volumes"`
	} `json:"spec"`
}

PodTemplate is spec.template of a workload.

type Volume

type Volume struct {
	Name string `json:"name"`
	CSI  *struct {
		Driver string `json:"driver"`
	} `json:"csi"`
}

Volume is a pod volume, with the one source a chart check looks at.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL