Commit 69aa2d32 authored by James Massara's avatar James Massara

Simplied Tags configuration

parent 8bffb4f1
...@@ -29,7 +29,7 @@ type config struct { ...@@ -29,7 +29,7 @@ type config struct {
AMIName string `mapstructure:"ami_name"` AMIName string `mapstructure:"ami_name"`
// Tags for the AMI // Tags for the AMI
Tags []map[string]string Tags map[string]string
// Unexported fields that are calculated from others // Unexported fields that are calculated from others
ec2Tags []ec2.Tag ec2Tags []ec2.Tag
...@@ -63,24 +63,11 @@ func (b *Builder) Prepare(raws ...interface{}) error { ...@@ -63,24 +63,11 @@ func (b *Builder) Prepare(raws ...interface{}) error {
} }
} }
// Accumulate any errors // Convert Tags to ec2.Tag
if b.config.Tags != nil { if b.config.Tags != nil {
var ec2Tags []ec2.Tag var ec2Tags []ec2.Tag
for _, tag := range b.config.Tags { for key, value := range b.config.Tags {
if _, ok := tag["key"]; !ok { ec2Tags = append(ec2Tags, ec2.Tag{key, value})
errs = packer.MultiErrorAppend(
errs, fmt.Errorf("Unknown tag configuration, expecting 'key'"))
continue
}
if _, ok := tag["value"]; !ok {
errs = packer.MultiErrorAppend(
errs, fmt.Errorf("Unknown tag configuration, expecting 'value'"))
continue
}
ec2Tags = append(ec2Tags, ec2.Tag{
Key: tag["key"],
Value: tag["value"],
})
} }
b.config.ec2Tags = ec2Tags b.config.ec2Tags = ec2Tags
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment