From 8b72879453a396cfe5f384a76300c6afb98044a4 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 20 Jun 2013 12:18:03 -0700 Subject: [PATCH] Default cache to "packer_cache" in CWD --- packer.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/packer.go b/packer.go index 43edc77d0..a4662eb57 100644 --- a/packer.go +++ b/packer.go @@ -36,17 +36,19 @@ func main() { defer plugin.CleanupClients() - var cache packer.Cache - if cacheDir := os.Getenv("PACKER_CACHE_DIR"); cacheDir != "" { - if err := os.MkdirAll(cacheDir, 0755); err != nil { - fmt.Fprintf(os.Stderr, "Error preparing cache directory: \n\n%s\n", err) - os.Exit(1) - } - - log.Printf("Setting cache directory: %s", cacheDir) - cache = &packer.FileCache{CacheDir: cacheDir} + cacheDir := os.Getenv("PACKER_CACHE_DIR") + if cacheDir == "" { + cacheDir = "packer_cache" } + if err := os.MkdirAll(cacheDir, 0755); err != nil { + fmt.Fprintf(os.Stderr, "Error preparing cache directory: \n\n%s\n", err) + os.Exit(1) + } + + log.Printf("Setting cache directory: %s", cacheDir) + cache := &packer.FileCache{CacheDir: cacheDir} + envConfig := packer.DefaultEnvironmentConfig() envConfig.Cache = cache envConfig.Commands = config.CommandNames()