From 69aa2d32ac4bc053091d56d9364c3e0367f44ff5 Mon Sep 17 00:00:00 2001 From: James Massara Date: Tue, 6 Aug 2013 07:33:00 -0700 Subject: [PATCH] Simplied Tags configuration --- builder/amazon/ebs/builder.go | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/builder/amazon/ebs/builder.go b/builder/amazon/ebs/builder.go index fa9af4a15..9882b3631 100644 --- a/builder/amazon/ebs/builder.go +++ b/builder/amazon/ebs/builder.go @@ -29,7 +29,7 @@ type config struct { AMIName string `mapstructure:"ami_name"` // Tags for the AMI - Tags []map[string]string + Tags map[string]string // Unexported fields that are calculated from others ec2Tags []ec2.Tag @@ -63,24 +63,11 @@ func (b *Builder) Prepare(raws ...interface{}) error { } } - // Accumulate any errors + // Convert Tags to ec2.Tag if b.config.Tags != nil { var ec2Tags []ec2.Tag - for _, tag := range b.config.Tags { - if _, ok := tag["key"]; !ok { - 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"], - }) + for key, value := range b.config.Tags { + ec2Tags = append(ec2Tags, ec2.Tag{key, value}) } b.config.ec2Tags = ec2Tags }