Documentation
¶
Index ¶
Constants ¶
const VarEnvPrefix = "NOMAD_PACK_VAR_"
Variables ¶
This section is empty.
Functions ¶
func GetVarsFromEnv ¶
Types ¶
type ParsedVariables ¶
ParsedVariables wraps the parsed variables returned by parser.Parse and provides functionality to access them.
func (*ParsedVariables) ConvertVariablesToMapInterface ¶
func (p *ParsedVariables) ConvertVariablesToMapInterface() (map[string]interface{}, hcl.Diagnostics)
ConvertVariablesToMapInterface translates the parsed variables into their native go types. The returned map is always keyed by the pack namespace for the variables.
Even though parsing the variable went without error, it is highly possible that conversion to native go types can incur an error. If an error is returned, it should be considered terminal.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser can parse, merge, and validate HCL variables from multiple different sources.
func NewParser ¶
func NewParser(cfg *ParserConfig) (*Parser, error)
func (*Parser) Parse ¶
func (p *Parser) Parse() (*ParsedVariables, hcl.Diagnostics)
type ParserConfig ¶
type ParserConfig struct {
// ParentName is the name representing the parent pack.
ParentName string
// RootVariableFiles contains a map of root variable files, keyed by their
// pack name.
RootVariableFiles map[string]*pack.File
// EnvOverrides are key=value variables and take the lowest precedence of
// all sources. If the same key is supplied twice, the last wins.
EnvOverrides map[string]string
// FileOverrides is a list of files which contain variable overrides in the
// form key=value. The files will be stored before processing to ensure a
// consistent processing experience. Overrides here will replace any
// default root declarations.
FileOverrides []string
// CLIOverrides are key=value variables and take the highest precedence of
// all sources. If the same key is supplied twice, the last wins.
CLIOverrides map[string]string
}
ParserConfig contains details of the numerous sources of variables which should be parsed and merged according to the expected strategy.
type Variable ¶
type Variable struct {
// Name is the variable label. This is used to identify variables being
// overridden and during templating.
Name string
// Description is an optional field which provides additional context to
// users identifying what the variable is used for.
Description string
// Type represents the concrete cty type of this variable. If the type is
// unable to be parsed into a cty type, it is invalid.
Type cty.Type
// Value stores the variable value and is used when converting the cty type
// value into a Go type value.
Value cty.Value
// DeclRange is the position marker of the variable within the file it was
// read from. This is used for diagnostics.
DeclRange hcl.Range
}
Variable encapsulates a single variable as defined within a block according to variableFileSchema and variableBlockSchema.