Documentation
¶
Overview ¶
Copyright 2026 YLD Limited SPDX-License-Identifier: Apache-2.0 Package hclparser evaluates HCL expressions into cty values. It handles literal values, template strings, binary operations, unary operations, scope traversals (variable references), and other HCL expression types. Variables can be registered and resolved during expression evaluation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BinaryOpExpr ¶
type BinaryOpExpr struct {
// contains filtered or unexported fields
}
BinaryOpExpr evaluates an HCL binary operation (e.g. +, -, ==) with variable support.
func NewBinaryOpExpr ¶
func NewBinaryOpExpr(expression *hclsyntax.BinaryOpExpr, hv *HCLVars) *BinaryOpExpr
NewBinaryOpExpr creates a BinaryOpExpr for the given expression and variable store.
type Expression ¶
type Expression struct {
// contains filtered or unexported fields
}
Expression wraps a generic HCL expression for direct evaluation.
func NewExpression ¶
func NewExpression(expression hcl.Expression) *Expression
NewExpression creates an Expression wrapper for the given HCL expression.
type HCLParser ¶
type HCLParser struct {
// contains filtered or unexported fields
}
HCLParser evaluates a single HCL expression, resolving variable references.
func New ¶
func New(expression hcl.Expression, hv *HCLVars) *HCLParser
New creates an HCLParser for the given expression and variable store.
type HCLVars ¶
type HCLVars struct {
// contains filtered or unexported fields
}
HCLVars is a key-value store for HCL variable values.
func (*HCLVars) GetValueByIndex ¶
GetValueByIndex returns an element from a list variable by key and index.
type LiteralValueExpr ¶
type LiteralValueExpr struct {
// contains filtered or unexported fields
}
LiteralValueExpr wraps an HCL literal value (string, number, bool).
func NewLiteralValueExpr ¶
func NewLiteralValueExpr(expression *hclsyntax.LiteralValueExpr) *LiteralValueExpr
NewLiteralValueExpr creates a LiteralValueExpr for the given HCL literal.
type ScopeTraversalExpr ¶
type ScopeTraversalExpr struct {
// contains filtered or unexported fields
}
ScopeTraversalExpr resolves an HCL scope traversal (e.g. var.name or var.list[0]) against a variable store.
func NewScopeTraversalExpr ¶
func NewScopeTraversalExpr(expression *hclsyntax.ScopeTraversalExpr, hv *HCLVars) *ScopeTraversalExpr
NewScopeTraversalExpr creates a ScopeTraversalExpr for the given traversal expression and variable store.
type TemplateExpr ¶
type TemplateExpr struct {
// contains filtered or unexported fields
}
TemplateExpr evaluates an HCL template string expression.
func NewTemplateExpr ¶
func NewTemplateExpr(expression *hclsyntax.TemplateExpr) *TemplateExpr
NewTemplateExpr creates a TemplateExpr for the given HCL template.
type VariableConfig ¶
VariableConfig represents a single HCL variable declaration with an id and value.
type VariableRef ¶
VariableRef holds the resolved attribute name and optional index from a traversal expression.
type VariablesConfig ¶
type VariablesConfig []VariableConfig
VariablesConfig is a slice of VariableConfig decoded from HCL variable blocks.
func (*VariablesConfig) Parse ¶
func (config *VariablesConfig) Parse(hv *HCLVars) error
Parse registers all variable values into the given HCLVars store.