From 4cf9e360853e7513b0c3be2e4f8815638b0cae5d Mon Sep 17 00:00:00 2001 From: Christopher Gerber Date: Wed, 3 Feb 2016 10:43:48 -0600 Subject: [PATCH] Changes credential/config file opener to use homedir instead of HOME environmental variable. --- builder/amazon/common/cli_config.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/builder/amazon/common/cli_config.go b/builder/amazon/common/cli_config.go index 2b1b2c014..9b8e63286 100644 --- a/builder/amazon/common/cli_config.go +++ b/builder/amazon/common/cli_config.go @@ -9,6 +9,7 @@ import ( "github.com/aws/aws-sdk-go/aws/credentials" "github.com/aws/aws-sdk-go/service/sts" "github.com/go-ini/ini" + "github.com/mitchellh/go-homedir" ) type CLIConfig struct { @@ -64,7 +65,7 @@ func (c *CLIConfig) Prepare(name string) (error) { func (c *CLIConfig) config() (*ini.File, error) { config_path := os.Getenv("AWS_CONFIG_FILE") if config_path == "" { - config_path = path.Join(os.Getenv("HOME"), ".aws", "config") + config_path = path.Join(homedir.Dir(), ".aws", "config") } ini, err := c.readFile(config_path) if err != nil { @@ -76,8 +77,9 @@ func (c *CLIConfig) config() (*ini.File, error) { func (c *CLIConfig) credentials() (*ini.File, error) { cred_path := os.Getenv("AWS_SHARED_CREDENTIALS_FILE") + home := if cred_path == "" { - cred_path = path.Join(os.Getenv("HOME"), ".aws", "credentials") + cred_path = path.Join(homedir.Dir(), ".aws", "credentials") } ini, err := c.readFile(cred_path) if err != nil {