Commit cad67897 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

Merge pull request #199 from qur/builder-name

packer: builder name should be removed from rawConfig
parents f415fc18 40897fdf
...@@ -161,6 +161,10 @@ func ParseTemplate(data []byte) (t *Template, err error) { ...@@ -161,6 +161,10 @@ func ParseTemplate(data []byte) (t *Template, err error) {
continue continue
} }
// Now that we have the name, remove it from the config - as the builder
// itself doesn't know about, and it will cause a validation error.
delete(v, "name")
raw.rawConfig = v raw.rawConfig = v
t.Builders[raw.Name] = raw t.Builders[raw.Name] = raw
......
...@@ -128,6 +128,19 @@ func TestParseTemplate_BuilderWithName(t *testing.T) { ...@@ -128,6 +128,19 @@ func TestParseTemplate_BuilderWithName(t *testing.T) {
builder, ok := result.Builders["bob"] builder, ok := result.Builders["bob"]
assert.True(ok, "should have bob builder") assert.True(ok, "should have bob builder")
assert.Equal(builder.Type, "amazon-ebs", "builder should be amazon-ebs") assert.Equal(builder.Type, "amazon-ebs", "builder should be amazon-ebs")
rawConfig := builder.rawConfig
if rawConfig == nil {
t.Fatal("missing builder raw config")
}
expected := map[string]interface{}{
"type": "amazon-ebs",
}
if !reflect.DeepEqual(rawConfig, expected) {
t.Fatalf("bad raw: %#v", rawConfig)
}
} }
func TestParseTemplate_BuilderWithConflictingName(t *testing.T) { func TestParseTemplate_BuilderWithConflictingName(t *testing.T) {
......
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