fix source accessor to allow use in source block

This commit is contained in:
Megan Marsh 2021-10-08 11:33:52 -07:00
parent 7ebc85564b
commit cdde5cbbe2

View file

@ -110,6 +110,12 @@ func (cfg *PackerConfig) startBuilder(source SourceUseBlock, ectx *hcl.EvalConte
}
body := source.Body
// Add known values to source accessor in eval context.
ectx.Variables[sourcesAccessor] = cty.ObjectVal(map[string]cty.Value{
"type": cty.StringVal(source.Type),
"name": cty.StringVal(source.Name),
})
decoded, moreDiags := decodeHCL2Spec(body, ectx, builder)
diags = append(diags, moreDiags...)
if moreDiags.HasErrors() {