pass source name from local source name too
This commit is contained in:
parent
cf514d31f2
commit
eaf63e3bb5
|
@ -369,10 +369,7 @@ func (cfg *PackerConfig) GetBuilds(opts packer.GetBuildsOptions) ([]packer.Build
|
|||
}
|
||||
|
||||
variables := map[string]cty.Value{
|
||||
sourcesAccessor: cty.ObjectVal(map[string]cty.Value{
|
||||
"type": cty.StringVal(src.Type),
|
||||
"name": cty.StringVal(src.Name),
|
||||
}),
|
||||
sourcesAccessor: cty.ObjectVal(src.ctyValues()),
|
||||
buildAccessor: cty.ObjectVal(unknownBuildValues),
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
"github.com/hashicorp/hcl/v2"
|
||||
"github.com/hashicorp/hcl/v2/gohcl"
|
||||
"github.com/hashicorp/packer/packer"
|
||||
"github.com/zclconf/go-cty/cty"
|
||||
)
|
||||
|
||||
// SourceBlock references an HCL 'source' block.
|
||||
|
@ -26,11 +27,23 @@ type SourceBlock struct {
|
|||
LocalName string
|
||||
}
|
||||
|
||||
func (b *SourceBlock) String() string {
|
||||
func (b *SourceBlock) name() string {
|
||||
if b.LocalName != "" {
|
||||
return fmt.Sprintf("%s.%s", b.Type, b.LocalName)
|
||||
return b.LocalName
|
||||
}
|
||||
return b.Name
|
||||
}
|
||||
|
||||
func (b *SourceBlock) String() string {
|
||||
return fmt.Sprintf("%s.%s", b.Type, b.name())
|
||||
}
|
||||
|
||||
// EvalContext adds the values of the source to the passed eval context.
|
||||
func (b *SourceBlock) ctyValues() map[string]cty.Value {
|
||||
return map[string]cty.Value{
|
||||
"type": cty.StringVal(b.Type),
|
||||
"name": cty.StringVal(b.name()),
|
||||
}
|
||||
return fmt.Sprintf("%s.%s", b.Type, b.Name)
|
||||
}
|
||||
|
||||
// decodeBuildSource reads a used source block from a build:
|
||||
|
|
Loading…
Reference in New Issue