From f2c8b994a0af10cc79c8c2d6ac5519c229985886 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 9 Jun 2013 21:18:06 -0700 Subject: [PATCH] packer: Default cache is just to os temporary dir --- packer/environment.go | 5 +++++ packer/environment_test.go | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/packer/environment.go b/packer/environment.go index ff48d7264..c4586fd44 100644 --- a/packer/environment.go +++ b/packer/environment.go @@ -104,6 +104,11 @@ func NewEnvironment(config *EnvironmentConfig) (resultEnv Environment, err error env.components.Provisioner = func(string) (Provisioner, error) { return nil, nil } } + // The default cache is just the system temporary directory + if env.cache == nil { + env.cache = &FileCache{CacheDir: os.TempDir()} + } + resultEnv = env return } diff --git a/packer/environment_test.go b/packer/environment_test.go index 43aff9854..16bf11854 100644 --- a/packer/environment_test.go +++ b/packer/environment_test.go @@ -111,6 +111,14 @@ func TestEnvironment_Builder_Error(t *testing.T) { assert.Nil(returnedBuilder, "should be no builder") } +func TestEnvironment_Cache(t *testing.T) { + config := DefaultEnvironmentConfig() + env, _ := NewEnvironment(config) + if env.Cache() == nil { + t.Fatal("cache should not be nil") + } +} + func TestEnvironment_Cli_Error(t *testing.T) { assert := asserts.NewTestingAsserts(t, true)