packer: Make builder type available in configs [GH-154]

This commit is contained in:
Mitchell Hashimoto 2013-07-15 09:58:32 +09:00
parent a47ad137a0
commit b1c7d93ee8
5 changed files with 49 additions and 40 deletions

View File

@ -11,6 +11,11 @@ const (
// build.
BuildNameConfigKey = "packer_build_name"
// This is the key in the configuration that is set to the type
// of the builder that is run. This is useful for provisioners and
// such who want to make use of this.
BuilderTypeConfigKey = "packer_builder_type"
// This is the key in configurations that is set to "true" when Packer
// debugging is enabled.
DebugConfigKey = "packer_debug"
@ -110,6 +115,7 @@ func (b *coreBuild) Prepare() (err error) {
packerConfig := map[string]interface{}{
BuildNameConfigKey: b.name,
BuilderTypeConfigKey: b.builderType,
DebugConfigKey: b.debug,
ForceConfigKey: b.force,
}

View File

@ -11,6 +11,7 @@ func testBuild() *coreBuild {
name: "test",
builder: &TestBuilder{artifactId: "b"},
builderConfig: 42,
builderType: "foo",
hooks: map[string][]Hook{
"foo": []Hook{&TestHook{}},
},
@ -41,6 +42,7 @@ func TestBuild_Prepare(t *testing.T) {
packerConfig := map[string]interface{}{
BuildNameConfigKey: "test",
BuilderTypeConfigKey: "foo",
DebugConfigKey: false,
ForceConfigKey: false,
}
@ -88,6 +90,7 @@ func TestBuild_Prepare_Debug(t *testing.T) {
packerConfig := map[string]interface{}{
BuildNameConfigKey: "test",
BuilderTypeConfigKey: "foo",
DebugConfigKey: true,
ForceConfigKey: false,
}

View File

@ -2,8 +2,8 @@ package packer
import (
"cgl.tideland.biz/asserts"
"sort"
"reflect"
"sort"
"testing"
)