From 0ba289fc85d10b2daee4888a777cda2f14223286 Mon Sep 17 00:00:00 2001 From: Stephen Kitt Date: Mon, 17 Jan 2022 12:13:41 +0100 Subject: [PATCH 1/3] Rely on os.UserHomeDir() Instead of hard-coding Windows and *nix environment variables, rely on os.UserHomeDir() to do the right thing. Ignore errors since those only happen in situations we don't care about (and didn't handle previously). Signed-off-by: Stephen Kitt --- config/shared_config.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/config/shared_config.go b/config/shared_config.go index b82926df976..37b4b1d7368 100644 --- a/config/shared_config.go +++ b/config/shared_config.go @@ -1051,12 +1051,9 @@ func (e CredentialRequiresARNError) Error() string { } func userHomeDir() string { - if runtime.GOOS == "windows" { // Windows - return os.Getenv("USERPROFILE") - } - - // *nix - return os.Getenv("HOME") + // Ignore errors since we only care about Windows and *nix. + homedir, _ := os.UserHomeDir() + return homedir } func oneOrNone(bs ...bool) bool { From 39691e9dd56ae5df4eb7899a46eea706209c0d85 Mon Sep 17 00:00:00 2001 From: Jason Del Ponte <961963+jasdel@users.noreply.github.com> Date: Thu, 20 Jan 2022 09:52:41 -0800 Subject: [PATCH 2/3] remove unused import --- config/shared_config.go | 1 - 1 file changed, 1 deletion(-) diff --git a/config/shared_config.go b/config/shared_config.go index 37b4b1d7368..ca48df8794c 100644 --- a/config/shared_config.go +++ b/config/shared_config.go @@ -6,7 +6,6 @@ import ( "fmt" "os" "path/filepath" - "runtime" "strings" "time" From d33d3481602dc1683a96693d9ce6afa9e2e15336 Mon Sep 17 00:00:00 2001 From: Jason Del Ponte <961963+jasdel@users.noreply.github.com> Date: Thu, 20 Jan 2022 09:52:48 -0800 Subject: [PATCH 3/3] add changelog --- .changelog/4f325261c632499cb3f4464799763f58.json | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .changelog/4f325261c632499cb3f4464799763f58.json diff --git a/.changelog/4f325261c632499cb3f4464799763f58.json b/.changelog/4f325261c632499cb3f4464799763f58.json new file mode 100644 index 00000000000..c440d7cd745 --- /dev/null +++ b/.changelog/4f325261c632499cb3f4464799763f58.json @@ -0,0 +1,8 @@ +{ + "id": "4f325261-c632-499c-b3f4-464799763f58", + "type": "bugfix", + "description": "Updates `config` module to use os.UserHomeDir instead of hard coded environment variable for OS. [#1563](https://github.com/aws/aws-sdk-go-v2/pull/1563)", + "modules": [ + "config" + ] +} \ No newline at end of file