interpolation

package
v1.20.2 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2023 License: Apache-2.0 Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Interpolate

func Interpolate(config map[string]interface{}, opts Options) (map[string]interface{}, error)

Interpolate replaces variables in a string with the values from a mapping

Types

type Cast

type Cast func(value string) (interface{}, error)

Cast a value to a new type, or return an error if the value can't be cast

type LookupValue

type LookupValue func(key string) (string, bool)

LookupValue is a function which maps from variable names to values. Returns the value as a string and a bool indicating whether the value is present, to distinguish between an empty string and the absence of a value.

type Options

type Options struct {
	// LookupValue from a key
	LookupValue LookupValue
	// TypeCastMapping maps key paths to functions to cast to a type
	TypeCastMapping map[tree.Path]Cast
	// Substitution function to use
	Substitute func(string, template.Mapping) (string, error)
}

Options supported by Interpolate

Jump to

Keyboard shortcuts

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