engine

package
v4.0.0-...-d1d7bb9 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Package engine implements the Go text template engine as needed for Helm.

When Helm renders templates it does so with additional functions and different modes (e.g., strict, lint mode). This package handles the helm specific implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLookupFunction

func NewLookupFunction(config *rest.Config) lookupFunc

NewLookupFunction returns a function for looking up objects in the cluster.

If the resource does not exist, no error is raised.

This function is considered deprecated, and will be renamed in Helm 4. It will no longer be a public function.

func Render

func Render(chrt *chart.Chart, values chartutil.Values) (map[string]string, error)

Render takes a chart, optional values, and value overrides, and attempts to render the Go templates using the default options.

func RenderWithClient

func RenderWithClient(chrt *chart.Chart, values chartutil.Values, config *rest.Config) (map[string]string, error)

RenderWithClient takes a chart, optional values, and value overrides, and attempts to render the Go templates using the default options. This engine is client aware and so can have template functions that interact with the client.

func RenderWithClientProvider

func RenderWithClientProvider(chrt *chart.Chart, values chartutil.Values, clientProvider ClientProvider) (map[string]string, error)

RenderWithClientProvider takes a chart, optional values, and value overrides, and attempts to render the Go templates using the default options. This engine is client aware and so can have template functions that interact with the client. This function differs from RenderWithClient in that it lets you customize the way a dynamic client is constructed.

Types

type ClientProvider

type ClientProvider interface {
	// GetClientFor returns a dynamic.NamespaceableResourceInterface suitable for interacting with resources
	// corresponding to the provided apiVersion and kind, as well as a boolean indicating whether the resources
	// are namespaced.
	GetClientFor(apiVersion, kind string) (dynamic.NamespaceableResourceInterface, bool, error)
}

type Engine

type Engine struct {
	// If strict is enabled, template rendering will fail if a template references
	// a value that was not passed in.
	Strict bool
	// In LintMode, some 'required' template values may be missing, so don't fail
	LintMode bool

	// EnableDNS tells the engine to allow DNS lookups when rendering templates
	EnableDNS bool
	// contains filtered or unexported fields
}

Engine is an implementation of the Helm rendering implementation for templates.

func New

func New(config *rest.Config) Engine

New creates a new instance of Engine using the passed in rest config.

func (Engine) Render

func (e Engine) Render(chrt *chart.Chart, values chartutil.Values) (map[string]string, error)

Render takes a chart, optional values, and value overrides, and attempts to render the Go templates.

Render can be called repeatedly on the same engine.

This will look in the chart's 'templates' data (e.g. the 'templates/' directory) and attempt to render the templates there using the values passed in.

Values are scoped to their templates. A dependency template will not have access to the values set for its parent. If chart "foo" includes chart "bar", "bar" will not have access to the values for "foo".

Values should be prepared with something like `chartutils.ReadValues`.

Values are passed through the templates according to scope. If the top layer chart includes the chart foo, which includes the chart bar, the values map will be examined for a table called "foo". If "foo" is found in vals, that section of the values will be passed into the "foo" chart. And if that section contains a value named "bar", that value will be passed on to the bar chart during render time.

Jump to

Keyboard shortcuts

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