Skip to content

Commit 7d859d0

Browse files
committed
chore: vars update
1 parent 5f3b26f commit 7d859d0

3 files changed

Lines changed: 12 additions & 5 deletions

File tree

internal/hclparse/autoinclude.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ func resolveDependencyBlock(block *hclsyntax.Block, evalCtx *hcl.EvalContext) (A
150150
// context by the caller.
151151
func BuildAutoIncludeEvalContext(unitRefs, stackRefs []ComponentRef) *hcl.EvalContext {
152152
vars := map[string]cty.Value{
153-
"unit": BuildComponentRefMap(unitRefs),
154-
"stack": BuildComponentRefMap(stackRefs),
153+
varUnit: BuildComponentRefMap(unitRefs),
154+
varStack: BuildComponentRefMap(stackRefs),
155155
}
156156

157157
return &hcl.EvalContext{

internal/hclparse/parse.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ import (
1414
const (
1515
// StackDir is the directory name where generated stack components are placed.
1616
StackDir = ".terragrunt-stack"
17+
18+
// HCL variable root names used in eval context.
19+
varLocal = "local"
20+
varValues = "values"
21+
varUnit = "unit"
22+
varStack = "stack"
23+
varDependency = "dependency"
1724
)
1825

1926
// ParseResult holds the output of a two-pass parse of a terragrunt.stack.hcl file.
@@ -70,7 +77,7 @@ func ParseStackFile(src []byte, filename string, stackDir string, values *cty.Va
7077

7178
// Add values to context if provided.
7279
if values != nil {
73-
evalCtx.Variables["values"] = *values
80+
evalCtx.Variables[varValues] = *values
7481
}
7582

7683
// Evaluate locals block iteratively.
@@ -153,7 +160,7 @@ func evaluateLocals(body hcl.Body, evalCtx *hcl.EvalContext) {
153160
break
154161
}
155162

156-
evalCtx.Variables["local"] = cty.ObjectVal(evaluated)
163+
evalCtx.Variables[varLocal] = cty.ObjectVal(evaluated)
157164
}
158165
}
159166

internal/hclparse/partial_eval.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313

1414
// deferredRoots lists variable root names that cannot be evaluated at generation time.
1515
var deferredRoots = map[string]bool{
16-
"dependency": true,
16+
varDependency: true,
1717
}
1818

1919
// PartialEval walks an hclsyntax.Expression tree and returns HCL source text.

0 commit comments

Comments
 (0)