Documentation ¶
Index ¶
- Variables
- func Funcs(ctx *Context) template.FuncMap
- func Render(v string, ctx *Context) (string, error)
- func RenderInterface(v interface{}, ctx *Context) (interface{}, error)
- func RenderMap(v interface{}, ctx *Context, f *RenderFilter) (map[string]interface{}, error)
- func Validate(v string, ctx *Context) error
- func ValidateInterface(v interface{}, ctx *Context) error
- type Context
- type FuncGenerator
- type I
- type RenderFilter
Constants ¶
This section is empty.
Variables ¶
var FuncGens = map[string]FuncGenerator{ "build_name": funcGenBuildName, "build_type": funcGenBuildType, "env": funcGenEnv, "isotime": funcGenIsotime, "pwd": funcGenPwd, "template_dir": funcGenTemplateDir, "timestamp": funcGenTimestamp, "uuid": funcGenUuid, "user": funcGenUser, "packer_version": funcGenPackerVersion, "upper": funcGenPrimitive(strings.ToUpper), "lower": funcGenPrimitive(strings.ToLower), }
Funcs are the interpolation funcs that are available within interpolations.
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.
Functions ¶
func RenderInterface ¶
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 ValidateInterface ¶
ValidateInterface renders any value and returns the resulting value.
Types ¶
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 // 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.
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.
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.