v1.6.5 Latest Latest

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

Go to latest
Published: Oct 30, 2020 License: MPL-2.0 Imports: 21 Imported by: 0




This section is empty.


View Source
var ErrVariableNotSetString = "Error: variable not set:"
View Source
var FuncGens = map[string]interface{}{
	"build_name":         funcGenBuildName,
	"build_type":         funcGenBuildType,
	"env":                funcGenEnv,
	"isotime":            funcGenIsotime,
	"strftime":           funcGenStrftime,
	"pwd":                funcGenPwd,
	"split":              funcGenSplitter,
	"template_dir":       funcGenTemplateDir,
	"timestamp":          funcGenTimestamp,
	"uuid":               funcGenUuid,
	"user":               funcGenUser,
	"packer_version":     funcGenPackerVersion,
	"consul_key":         funcGenConsul,
	"vault":              funcGenVault,
	"sed":                funcGenSed,
	"build":              funcGenBuild,
	"aws_secretsmanager": funcGenAwsSecrets,

	"replace":     replace,
	"replace_all": replace_all,

	"upper": strings.ToUpper,
	"lower": strings.ToLower,

Funcs are the interpolation funcs that are available within interpolations.

View Source
var InitTime time.Time

InitTime is the UTC time when this package was initialized. It is used as the timestamp for all configuration templates so that they match for a single build.


func Funcs

func Funcs(ctx *Context) template.FuncMap

Funcs returns the functions that can be used for interpolation given a context.

func Render

func Render(v string, ctx *Context) (rendered string, err error)

Render is shorthand for constructing an I and calling Render until all variables are rendered.

func RenderInterface

func RenderInterface(v interface{}, ctx *Context) (interface{}, error)

RenderInterface renders any value and returns the resulting value.

func RenderMap

func RenderMap(v interface{}, ctx *Context, f *RenderFilter) (map[string]interface{}, error)

RenderMap renders all the strings in the given interface. The interface must decode into a map[string]interface{}, but is left as an interface{} type to ease backwards compatibility with the way arguments are passed around in Packer.

func RenderOnce added in v1.5.3

func RenderOnce(v string, ctx *Context) (string, error)

RenderOnce is shorthand for constructing an I and calling Render one time.

func RenderRegex added in v1.5.2

func RenderRegex(v string, ctx *Context, regex string) (string, error)

Render is shorthand for constructing an I and calling Render. Use regex to filter variables that are not supposed to be interpolated now

func Validate

func Validate(v string, ctx *Context) error

Validate is shorthand for constructing an I and calling Validate.

func ValidateInterface

func ValidateInterface(v interface{}, ctx *Context) error

ValidateInterface renders any value and returns the resulting value.


type Context

type Context struct {
	// Data is the data for the template that is available
	Data interface{}

	// Funcs are extra functions available in the template
	Funcs map[string]interface{}

	// UserVariables is the mapping of user variables that the
	// "user" function reads from.
	UserVariables map[string]string

	// SensitiveVariables is a list of variables to sanitize.
	SensitiveVariables []string

	// EnableEnv enables the env function
	EnableEnv bool

	// All the fields below are used for built-in functions.
	// BuildName and BuildType are the name and type, respectively,
	// of the builder being used.
	// TemplatePath is the path to the template that this is being
	// rendered within.
	BuildName    string
	BuildType    string
	TemplatePath string

Context is the context that an interpolation is done in. This defines things such as available variables.

func NewContext added in v1.4.4

func NewContext() *Context

NewContext returns an initialized empty context.

type FuncGenerator

type FuncGenerator func(*Context) interface{}

FuncGenerator is a function that given a context generates a template function for the template.

type I

type I struct {
	Value string

I stands for "interpolation" and is the main interpolation struct in order to render values.

func (*I) Render

func (i *I) Render(ictx *Context) (string, error)

Render renders the interpolation with the given context.

func (*I) Validate

func (i *I) Validate(ctx *Context) error

Validate validates that the template is syntactically valid.

type RenderFilter

type RenderFilter struct {
	Include []string
	Exclude []string
	// contains filtered or unexported fields

RenderFilter is an option for filtering what gets rendered and doesn't within an interface.


Path Synopsis
Package secretsmanager provide methods to get data from AWS Secret Manager
Package secretsmanager provide methods to get data from AWS Secret Manager

Jump to

Keyboard shortcuts

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