From 05e254a2ffc4d7a38365ac95d64d45252ac663a1 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 20 Apr 2013 19:31:42 -0600 Subject: [PATCH] BuilderFactory getter on Environment --- packer/environment.go | 5 +++++ packer/environment_test.go | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/packer/environment.go b/packer/environment.go index a0f7dad42..d9f47d2fe 100644 --- a/packer/environment.go +++ b/packer/environment.go @@ -80,6 +80,11 @@ func NewEnvironment(config *EnvironmentConfig) (env *Environment, err error) { return } +// Returns the BuilderFactory associated with this Environment. +func (e *Environment) BuilderFactory() BuilderFactory { + return e.builderFactory +} + // Executes a command as if it was typed on the command-line interface. // The return value is the exit code of the command. func (e *Environment) Cli(args []string) int { diff --git a/packer/environment_test.go b/packer/environment_test.go index ad8decc60..63d5a8127 100644 --- a/packer/environment_test.go +++ b/packer/environment_test.go @@ -60,6 +60,15 @@ func TestNewEnvironment_NoConfig(t *testing.T) { assert.NotNil(err, "should be an error") } +func TestEnvironment_GetBuilderFactory(t *testing.T) { + assert := asserts.NewTestingAsserts(t, true) + + config := DefaultEnvironmentConfig() + env, _ := NewEnvironment(config) + + assert.Equal(env.BuilderFactory(), config.BuilderFactory, "should match factories") +} + func TestEnvironment_Cli_CallsRun(t *testing.T) { assert := asserts.NewTestingAsserts(t, true)