From 98db68e36cceb1f521d476b7ca7aaa280b66d9d1 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 29 Jun 2015 09:49:11 -0700 Subject: [PATCH] builder/amazon/instance: set valid bundle prefix [GH-2328] --- builder/amazon/instance/builder.go | 12 +++++++----- builder/amazon/instance/builder_test.go | 1 - 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/builder/amazon/instance/builder.go b/builder/amazon/instance/builder.go index 17760d918..6375c9e0d 100644 --- a/builder/amazon/instance/builder.go +++ b/builder/amazon/instance/builder.go @@ -50,6 +50,12 @@ type Builder struct { } func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { + configs := make([]interface{}, len(raws)+1) + configs[0] = map[string]interface{}{ + "bundle_prefix": "image-{{timestamp}}", + } + copy(configs[1:], raws) + b.config.ctx.Funcs = awscommon.TemplateFuncs err := config.Decode(&b.config, &config.DecodeOpts{ Interpolate: true, @@ -60,7 +66,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { "bundle_vol_command", }, }, - }, raws...) + }, configs...) if err != nil { return nil, err } @@ -69,10 +75,6 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { b.config.BundleDestination = "/tmp" } - if b.config.BundlePrefix == "" { - b.config.BundlePrefix = "image-{{timestamp}}" - } - if b.config.BundleUploadCommand == "" { if b.config.IamInstanceProfile != "" { b.config.BundleUploadCommand = "sudo -i -n ec2-upload-bundle " + diff --git a/builder/amazon/instance/builder_test.go b/builder/amazon/instance/builder_test.go index e15c45131..bb18e54a8 100644 --- a/builder/amazon/instance/builder_test.go +++ b/builder/amazon/instance/builder_test.go @@ -130,7 +130,6 @@ func TestBuilderPrepare_BundlePrefix(t *testing.T) { b := &Builder{} config := testConfig() - config["bundle_prefix"] = "" warnings, err := b.Prepare(config) if len(warnings) > 0 { t.Fatalf("bad: %#v", warnings)