From e9d3826219bbf4ebd3f4130f9a9742b622b8efd5 Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Wed, 4 Mar 2020 13:19:07 +0100 Subject: [PATCH] variables: use Range instead of Block because a variable can be defined in the Locals block --- hcl2template/types.variables.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hcl2template/types.variables.go b/hcl2template/types.variables.go index b15071e2a..55158379b 100644 --- a/hcl2template/types.variables.go +++ b/hcl2template/types.variables.go @@ -47,7 +47,7 @@ type Variable struct { // the variable from the output stream. By replacing the text. Sensitive bool - block *hcl.Block + Range hcl.Range } func (v *Variable) GoString() string { @@ -74,7 +74,7 @@ func (v *Variable) Value() (cty.Value, *hcl.Diagnostic) { Summary: fmt.Sprintf("Unset variable %q", v.Name), Detail: "A used variable must be set or have a default value; see " + "https://packer.io/docs/configuration/from-1.5/syntax.html for details.", - Context: v.block.DefRange.Ptr(), + Context: v.Range.Ptr(), } } @@ -120,7 +120,7 @@ func (variables *Variables) decodeVariable(key string, attr *hcl.Attribute, ectx Name: key, DefaultValue: value, Type: value.Type(), - // block: attr, + Range: attr.Range, } return diags @@ -159,7 +159,7 @@ func (variables *Variables) decodeVariableBlock(block *hcl.Block, ectx *hcl.Eval Name: name, Description: b.Description, Sensitive: b.Sensitive, - block: block, + Range: block.DefRange, } attrs, moreDiags := b.Rest.JustAttributes()