Documentation ¶
Index ¶
- Constants
- func Functions(basedir string, allowFS bool) map[string]function.Function
- func Parse(path string, r io.Reader) (*api.Job, error)
- func ParseWithConfig(args *ParseConfig) (*api.Job, error)
- type LocalBlock
- type ParseConfig
- type Variable
- type VariableAssignment
- type VariableValidation
- type Variables
Constants ¶
const VarEnvPrefix = "NOMAD_VAR_"
Prefix your environment variables with VarEnvPrefix so that Packer can see them.
Variables ¶
This section is empty.
Functions ¶
func Functions ¶
Functions returns the set of functions that should be used to when evaluating expressions in the receiving scope.
basedir is used with file functions and allows a user to reference a file using local path. Usually basedir is the directory in which the config file is located
func ParseWithConfig ¶
func ParseWithConfig(args *ParseConfig) (*api.Job, error)
Types ¶
type LocalBlock ¶
type LocalBlock struct { Name string Expr hcl.Expression }
Local represents a single entry from a "locals" block in a file. The "locals" block itself is not represented, because it serves only to provide context for us to interpret its contents.
type ParseConfig ¶
type ParseConfig struct { Path string BaseDir string // Body is the HCL body Body []byte // AllowFS enables HCL functions that require file system access AllowFS bool // ArgVars is the CLI -var arguments ArgVars []string // VarFiles is the paths of variable data files that should be read during // parsing. VarFiles []string // VarContent is the content of variable data known without reading an // actual var file during parsing. VarContent string // Envs represent process environment variable Envs []string Strict bool // contains filtered or unexported fields }
type Variable ¶
type Variable struct { // Values contains possible values for the variable; The last value set // from these will be the one used. If none is set; an error will be // returned by Value(). Values []VariableAssignment // Validations contains all variables validation rules to be applied to the // used value. Only the used value - the last value from Values - is // validated. Validations []*VariableValidation // Cty Type of the variable. If the default value or a collected value is // not of this type nor can be converted to this type an error diagnostic // will show up. This allows us to assume that values are valid later in // code. // // When a default value - and no type - is passed in the variable // declaration, the type of the default variable will be used. This will // allow to ensure that users set this variable correctly. Type cty.Type // Common name of the variable Name string // Description of the variable Description string Range hcl.Range }
type VariableAssignment ¶
type VariableAssignment struct { // From tells were it was taken from, command/varfile/env/default From string Value cty.Value Expr hcl.Expression }
VariableAssignment represents a way a variable was set: the expression setting it and the value of that expression. It helps pinpoint were something was set in diagnostics.
type VariableValidation ¶
type VariableValidation struct { // Condition is an expression that refers to the variable being tested and // contains no other references. The expression must return true to // indicate that the value is valid or false to indicate that it is // invalid. If the expression produces an error, that's considered a bug in // the block defining the validation rule, not an error in the caller. Condition hcl.Expression // ErrorMessage is one or more full sentences, which _should_ be in English // for consistency with the rest of the error message output but can in // practice be in any language as long as it ends with a period. The // message should describe what is required for the condition to return // true in a way that would make sense to a caller of the module. ErrorMessage string DeclRange hcl.Range }
VariableValidation represents a configuration-defined validation rule for a particular input variable, given as a "validation" block inside a "variable" block.