variables: use Range instead of Block
because a variable can be defined in the Locals block
This commit is contained in:
parent
9b649594c6
commit
e9d3826219
|
@ -47,7 +47,7 @@ type Variable struct {
|
||||||
// the variable from the output stream. By replacing the text.
|
// the variable from the output stream. By replacing the text.
|
||||||
Sensitive bool
|
Sensitive bool
|
||||||
|
|
||||||
block *hcl.Block
|
Range hcl.Range
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Variable) GoString() string {
|
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),
|
Summary: fmt.Sprintf("Unset variable %q", v.Name),
|
||||||
Detail: "A used variable must be set or have a default value; see " +
|
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.",
|
"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,
|
Name: key,
|
||||||
DefaultValue: value,
|
DefaultValue: value,
|
||||||
Type: value.Type(),
|
Type: value.Type(),
|
||||||
// block: attr,
|
Range: attr.Range,
|
||||||
}
|
}
|
||||||
|
|
||||||
return diags
|
return diags
|
||||||
|
@ -159,7 +159,7 @@ func (variables *Variables) decodeVariableBlock(block *hcl.Block, ectx *hcl.Eval
|
||||||
Name: name,
|
Name: name,
|
||||||
Description: b.Description,
|
Description: b.Description,
|
||||||
Sensitive: b.Sensitive,
|
Sensitive: b.Sensitive,
|
||||||
block: block,
|
Range: block.DefRange,
|
||||||
}
|
}
|
||||||
|
|
||||||
attrs, moreDiags := b.Rest.JustAttributes()
|
attrs, moreDiags := b.Rest.JustAttributes()
|
||||||
|
|
Loading…
Reference in New Issue