Help us shape the future of Go! Take the 2026 Go Developer Survey

helmaction

package
v1.20.3 Latest Latest
Warning

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

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

Documentation

Overview

Package helmaction finds the {{ ... }} actions of a Helm template source: where each one starts and ends, quoted strings and comments included, so the resolver rewrites templates and the runner blanks them with the same rules.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Blank

func Blank(source []byte) []byte

Blank replaces every action of source with the newlines it spanned, an unterminated one included, so the line numbers of what remains are unchanged.

func InAny

func InAny(pos int, actions []Action) bool

InAny reports whether pos falls within one of actions.

func InQuote

func InQuote(s string, pos int, actions []Action) bool

InQuote reports whether pos is inside a quoted string of the action of actions that contains it.

func Remove

func Remove(s string) string

Remove drops every terminated action from s.

Types

type Action

type Action struct {
	Start, End int
	// Comment is a {{/* ... */}} action.
	Comment bool
	// Unterminated actions have no closing "}}" outside quotes. They end after
	// the next "}}", or at the end of the source when there is none.
	Unterminated bool
}

Action is one {{ ... }} template action of a template source, as byte offsets.

func Code

func Code(s string) []Action

Code returns the terminated actions of s that are not comments.

func Scan

func Scan(s string) []Action

Scan returns every action of s in order of start. Quoted strings (", ' and `) are opaque, so a "}}" inside one does not end an action. A comment ends at its "*/" followed by "}}", as its text may hold quotes of its own. Scanning resumes just after the "{{" of an unterminated action, so the actions after it are still found, and may lie within it.

func Terminated

func Terminated(s string) []Action

Terminated returns the actions of s that have a closing "}}".

Jump to

Keyboard shortcuts

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