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)