Commit 98db68e3 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

builder/amazon/instance: set valid bundle prefix [GH-2328]

parent 1aef60ff
...@@ -50,6 +50,12 @@ type Builder struct { ...@@ -50,6 +50,12 @@ type Builder struct {
} }
func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { 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 b.config.ctx.Funcs = awscommon.TemplateFuncs
err := config.Decode(&b.config, &config.DecodeOpts{ err := config.Decode(&b.config, &config.DecodeOpts{
Interpolate: true, Interpolate: true,
...@@ -60,7 +66,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { ...@@ -60,7 +66,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
"bundle_vol_command", "bundle_vol_command",
}, },
}, },
}, raws...) }, configs...)
if err != nil { if err != nil {
return nil, err return nil, err
} }
...@@ -69,10 +75,6 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { ...@@ -69,10 +75,6 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
b.config.BundleDestination = "/tmp" b.config.BundleDestination = "/tmp"
} }
if b.config.BundlePrefix == "" {
b.config.BundlePrefix = "image-{{timestamp}}"
}
if b.config.BundleUploadCommand == "" { if b.config.BundleUploadCommand == "" {
if b.config.IamInstanceProfile != "" { if b.config.IamInstanceProfile != "" {
b.config.BundleUploadCommand = "sudo -i -n ec2-upload-bundle " + b.config.BundleUploadCommand = "sudo -i -n ec2-upload-bundle " +
......
...@@ -130,7 +130,6 @@ func TestBuilderPrepare_BundlePrefix(t *testing.T) { ...@@ -130,7 +130,6 @@ func TestBuilderPrepare_BundlePrefix(t *testing.T) {
b := &Builder{} b := &Builder{}
config := testConfig() config := testConfig()
config["bundle_prefix"] = ""
warnings, err := b.Prepare(config) warnings, err := b.Prepare(config)
if len(warnings) > 0 { if len(warnings) > 0 {
t.Fatalf("bad: %#v", warnings) t.Fatalf("bad: %#v", warnings)
......
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