Documentation ¶
Index ¶
- Constants
- func PackTemplateContextFuncs(isV1 bool) template.FuncMap
- func PackTemplateContextFuncsV1() template.FuncMap
- func PackTemplateContextFuncsV2() template.FuncMap
- type PackContextable
- type PackData
- type PackTemplateContext
- type ParsedVariables
- func (pv *ParsedVariables) AsOverrideFile() string
- func (pv *ParsedVariables) ConvertVariablesToMapInterface() (map[string]any, hcl.Diagnostics)
- func (pv *ParsedVariables) GetVars() map[pack.ID]map[variables.ID]*variables.Variable
- func (pv *ParsedVariables) IsV1() bool
- func (pv *ParsedVariables) IsV2() bool
- func (pv *ParsedVariables) LoadV1Result(in map[string]map[string]*variables.Variable) error
- func (pv *ParsedVariables) LoadV2Result(in map[pack.ID]map[variables.ID]*variables.Variable) error
- func (pv *ParsedVariables) ToPackTemplateContext(p *pack.Pack) (PackTemplateContext, hcl.Diagnostics)
- type Parser
- type ParserV1
- type ParserV2
Constants ¶
const CurrentPackKey = "_self"
const VarEnvPrefix = "NOMAD_PACK_VAR_"
Variables ¶
This section is empty.
Functions ¶
func PackTemplateContextFuncs ¶
PackTemplateContextFuncs returns a text/template FuncMap that are necessary to access the variables and metadata information stored in the template context
func PackTemplateContextFuncsV1 ¶
PackTemplateContextFuncsV1 returns the a funcMap with error-only functions with the same names as v2 ones, so users are presented with more informative errors than the generic go-template ones.
func PackTemplateContextFuncsV2 ¶
PackTemplateContextFuncsV2 returns the funcMap for the V2 Pack template context. These are added to other template functions provided in the Renderer
Types ¶
type PackContextable ¶
type PackContextable interface {
// contains filtered or unexported methods
}
type PackData ¶
PackData is the currently selected Pack's metadata and variables, normally stored at `CurrentPackKey` in a PackTemplateContext.
type PackTemplateContext ¶
type PackTemplateContext map[string]PackContextable
func (PackTemplateContext) Name ¶
func (p PackTemplateContext) Name() string
type ParsedVariables ¶
ParsedVariables wraps the parsed variables returned by parser.Parse and provides functionality to access them.
func (*ParsedVariables) AsOverrideFile ¶
func (pv *ParsedVariables) AsOverrideFile() string
AsOverrideFile formats a ParsedVariables so it can be used as a var-file. This is used in the `generate varfile` command.
func (*ParsedVariables) ConvertVariablesToMapInterface ¶
func (pv *ParsedVariables) ConvertVariablesToMapInterface() (map[string]any, hcl.Diagnostics)
ConvertVariablesToMapInterface creates the data object for V1 syntax templates.
func (*ParsedVariables) IsV1 ¶
func (pv *ParsedVariables) IsV1() bool
func (*ParsedVariables) IsV2 ¶
func (pv *ParsedVariables) IsV2() bool
func (*ParsedVariables) LoadV1Result ¶
LoadV1Result populates this ParsedVariables with the result from parser_v1.Parse(). This function errors if the ParsedVariable has already been loaded.
func (*ParsedVariables) LoadV2Result ¶
LoadV2Result populates this ParsedVariables with the result from parser_v2.Parse(). This function errors if the ParsedVariable has already been loaded.
func (*ParsedVariables) ToPackTemplateContext ¶
func (pv *ParsedVariables) ToPackTemplateContext(p *pack.Pack) (PackTemplateContext, hcl.Diagnostics)
ToPackTemplateContext creates a PackTemplateContext from this ParsedVariables. 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 interface {
Parse() (*ParsedVariables, hcl.Diagnostics)
}
type ParserV1 ¶
type ParserV1 struct {
// contains filtered or unexported fields
}
ParserV1 can parse, merge, and validate HCL variables from multiple different sources.
func NewParserV1 ¶
func NewParserV1(cfg *config.ParserConfig) (*ParserV1, error)
func (*ParserV1) Parse ¶
func (p *ParserV1) Parse() (*ParsedVariables, hcl.Diagnostics)
type ParserV2 ¶
type ParserV2 struct {
// contains filtered or unexported fields
}
func NewParserV2 ¶
func NewParserV2(cfg *config.ParserConfig) (*ParserV2, error)
func (*ParserV2) Parse ¶
func (p *ParserV2) Parse() (*ParsedVariables, hcl.Diagnostics)