mirror of
https://github.com/hashicorp/packer.git
synced 2026-04-22 06:37:02 -04:00
KeyValues.CopyOn: make sure a receiving nil map is set too
This commit is contained in:
parent
87d6b2433f
commit
c845436e32
10 changed files with 17 additions and 14 deletions
|
|
@ -202,7 +202,7 @@ type AlicloudImageConfig struct {
|
|||
|
||||
func (c *AlicloudImageConfig) Prepare(ctx *interpolate.Context) []error {
|
||||
var errs []error
|
||||
errs = append(errs, c.AlicloudImageTag.CopyOn(c.AlicloudImageTags)...)
|
||||
errs = append(errs, c.AlicloudImageTag.CopyOn(&c.AlicloudImageTags)...)
|
||||
if c.AlicloudImageName == "" {
|
||||
errs = append(errs, fmt.Errorf("image_name must be specified"))
|
||||
} else if len(c.AlicloudImageName) < 2 || len(c.AlicloudImageName) > 128 {
|
||||
|
|
|
|||
|
|
@ -259,7 +259,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
|
|||
var errs *packer.MultiError
|
||||
var warns []string
|
||||
|
||||
errs = packer.MultiErrorAppend(errs, b.config.RootVolumeTag.CopyOn(b.config.RootVolumeTags)...)
|
||||
errs = packer.MultiErrorAppend(errs, b.config.RootVolumeTag.CopyOn(&b.config.RootVolumeTags)...)
|
||||
errs = packer.MultiErrorAppend(errs, b.config.SourceAmiFilter.Prepare()...)
|
||||
|
||||
errs = packer.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...)
|
||||
|
|
|
|||
|
|
@ -151,8 +151,8 @@ func stringInSlice(s []string, searchstr string) bool {
|
|||
func (c *AMIConfig) Prepare(accessConfig *AccessConfig, ctx *interpolate.Context) []error {
|
||||
var errs []error
|
||||
|
||||
errs = append(errs, c.SnapshotTag.CopyOn(c.SnapshotTags)...)
|
||||
errs = append(errs, c.AMITag.CopyOn(c.AMITags)...)
|
||||
errs = append(errs, c.SnapshotTag.CopyOn(&c.SnapshotTags)...)
|
||||
errs = append(errs, c.AMITag.CopyOn(&c.AMITags)...)
|
||||
|
||||
if c.AMIName == "" {
|
||||
errs = append(errs, fmt.Errorf("ami_name must be specified"))
|
||||
|
|
|
|||
|
|
@ -430,7 +430,7 @@ func (c *RunConfig) Prepare(ctx *interpolate.Context) []error {
|
|||
{c.RunTags, c.RunTag},
|
||||
{c.SpotTags, c.SpotTag},
|
||||
} {
|
||||
errs = append(errs, s.kvs.CopyOn(s.tagMap)...)
|
||||
errs = append(errs, s.kvs.CopyOn(&s.tagMap)...)
|
||||
}
|
||||
|
||||
for _, preparer := range []interface{ Prepare() []error }{
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ func (bds BlockDevices) Prepare(ctx *interpolate.Context) (errs []error) {
|
|||
|
||||
for _, block := range bds {
|
||||
|
||||
errs = append(errs, block.Tag.CopyOn(block.Tags)...)
|
||||
errs = append(errs, block.Tag.CopyOn(&block.Tags)...)
|
||||
|
||||
if err := block.Prepare(ctx); err != nil {
|
||||
errs = append(errs, err)
|
||||
|
|
|
|||
|
|
@ -267,8 +267,8 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
|
|||
|
||||
// Validation
|
||||
var errs *packer.MultiError
|
||||
errs = packer.MultiErrorAppend(errs, c.ImageTag.CopyOn(c.ImageTags)...)
|
||||
errs = packer.MultiErrorAppend(errs, c.VmTag.CopyOn(c.VmTags)...)
|
||||
errs = packer.MultiErrorAppend(errs, c.ImageTag.CopyOn(&c.ImageTags)...)
|
||||
errs = packer.MultiErrorAppend(errs, c.VmTag.CopyOn(&c.VmTags)...)
|
||||
|
||||
if es := c.Comm.Prepare(&c.ctx); len(es) > 0 {
|
||||
errs = packer.MultiErrorAppend(errs, es...)
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ func (cf *TencentCloudRunConfig) Prepare(ctx *interpolate.Context) []error {
|
|||
cf.RunTags = make(map[string]string)
|
||||
}
|
||||
|
||||
errs = append(errs, cf.RunTag.CopyOn(cf.RunTags)...)
|
||||
errs = append(errs, cf.RunTag.CopyOn(&cf.RunTags)...)
|
||||
|
||||
return errs
|
||||
}
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ func (c *SourceMachineConfig) Prepare(ctx *interpolate.Context) []error {
|
|||
c.MachineTags = make(map[string]string)
|
||||
}
|
||||
|
||||
errs = append(errs, c.MachineTag.CopyOn(c.MachineTags)...)
|
||||
errs = append(errs, c.MachineTag.CopyOn(&c.MachineTags)...)
|
||||
|
||||
return errs
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ type TargetImageConfig struct {
|
|||
func (c *TargetImageConfig) Prepare(ctx *interpolate.Context) []error {
|
||||
var errs []error
|
||||
|
||||
errs = append(errs, c.ImageTag.CopyOn(c.ImageTags)...)
|
||||
errs = append(errs, c.ImageTag.CopyOn(&c.ImageTags)...)
|
||||
|
||||
if c.ImageName == "" {
|
||||
errs = append(errs, fmt.Errorf("An image_name must be specified"))
|
||||
|
|
|
|||
|
|
@ -9,9 +9,12 @@ type KeyValue struct {
|
|||
|
||||
type KeyValues []KeyValue
|
||||
|
||||
func (kvs KeyValues) CopyOn(to map[string]string) []error {
|
||||
func (kvs KeyValues) CopyOn(to *map[string]string) []error {
|
||||
if *to == nil {
|
||||
*to = map[string]string{}
|
||||
}
|
||||
for _, kv := range kvs {
|
||||
to[kv.Key] = kv.Value
|
||||
(*to)[kv.Key] = kv.Value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -22,7 +25,7 @@ type KVFilter struct {
|
|||
}
|
||||
|
||||
func (kvf *KVFilter) Prepare() []error {
|
||||
kvf.Filter.CopyOn(kvf.Filters)
|
||||
kvf.Filter.CopyOn(&kvf.Filters)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue