template

package
v0.35.2 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TemplaterGomplate = "gomplate"
)
View Source
const (
	TemplaterNone = "copy"
)
View Source
const (
	TemplaterSOPS = "sops"
)
View Source
const (
	TemplaterSprig = "sprig"
)

Variables

This section is empty.

Functions

func Exec

func Exec(command string, args []any, inputs ...string) (string, error)

Exec runs external binary and returns its standard output. Used as custom template function.

func Get

func Get(path string, varArgs ...any) (any, error)

Get returns value in map by dot-separated key path. First argument is dot-separated key path. Second argument is default value if key not found and is optional. Third argument is map to search in. Used as custom template function.

func HasKey

func HasKey(path string, varArgs ...any) (bool, error)

HasKey searches for any value by dot-separated key path in map. Used as custom template function.

func NewSOPSDecodeError added in v0.32.0

func NewSOPSDecodeError(err error) error

func ReadFile

func ReadFile(file string) (string, error)

ReadFile reads file and returns its contents as string. Used as custom template function.

func Required

func Required(warn string, val any) (any, error)

Required returns error if val is nil of empty string. Otherwise it returns the same val. Used as custom template function.

func RequiredEnv

func RequiredEnv(name string) (string, error)

RequiredEnv returns environment variable by name and errors if it is not defined. Used as custom template function.

func ToYaml

func ToYaml(v any) (string, error)

ToYaml renders data into YAML string. Used as custom template function.

func Tpl2yml

func Tpl2yml(ctx context.Context, tpl, yml string, data any, templaterName string, opts ...TemplaterOptions) error

Tpl2yml renders 'tpl' file to 'yml' file as go template.

Types

type SOPSDecodeError added in v0.32.0

type SOPSDecodeError struct {
	Err error
}

func (SOPSDecodeError) Error added in v0.32.0

func (err SOPSDecodeError) Error() string

func (SOPSDecodeError) Unwrap added in v0.32.0

func (err SOPSDecodeError) Unwrap() error

type Templater added in v0.17.0

type Templater interface {
	Name() string
	Delims(string, string)
	Render(context.Context, string, any) ([]byte, error)
}

Templater is interface for using different template function groups.

type TemplaterOptions added in v0.24.0

type TemplaterOptions func(Templater)

TemplaterOptions is a function that changes templater options.

func SetDelimiters added in v0.24.0

func SetDelimiters(left, right string) TemplaterOptions

type Values

type Values = map[string]any

Values is alias for string map of interfaces.

func FromYaml

func FromYaml(str string) (Values, error)

FromYaml parses YAML string into data. Used as custom template function.

func SetValueAtPath

func SetValueAtPath(path string, value any, values Values) (Values, error)

SetValueAtPath sets value in map by dot-separated key path. Used as custom template function.

Jump to

Keyboard shortcuts

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