Skip to content

Commit ac01f41

Browse files
committed
Merge pull request #3 from remind101/deal_with_dup_variables
Allow update of existing env vars
2 parents 25dfc34 + 43289e8 commit ac01f41

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

main.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,24 +56,25 @@ func execWithCredentials(argv []string, creds *credentials) error {
5656
return err
5757
}
5858

59+
os.Setenv("AWS_ACCESS_KEY_ID", creds.AccessKeyID)
60+
os.Setenv("AWS_SECRET_ACCESS_KEY", creds.SecretAccessKey)
61+
os.Setenv("AWS_SESSION_TOKEN", creds.SessionToken)
62+
os.Setenv("AWS_SECURITY_TOKEN", creds.SessionToken)
63+
5964
env := os.Environ()
60-
env = append(env, fmt.Sprintf("AWS_ACCESS_KEY_ID=%s", creds.AccessKeyId))
61-
env = append(env, fmt.Sprintf("AWS_SECRET_ACCESS_KEY=%s", creds.SecretAccessKey))
62-
env = append(env, fmt.Sprintf("AWS_SESSION_TOKEN=%s", creds.SessionToken))
63-
env = append(env, fmt.Sprintf("AWS_SECURITY_TOKEN=%s", creds.SessionToken))
6465
return syscall.Exec(argv0, argv, env)
6566
}
6667

6768
type credentials struct {
68-
AccessKeyId string
69+
AccessKeyID string
6970
SecretAccessKey string
7071
SessionToken string
7172
}
7273

7374
// printCredentials prints the credentials in a way that can easily be sourced
7475
// with bash.
7576
func printCredentials(creds *credentials) {
76-
fmt.Printf("export AWS_ACCESS_KEY_ID=\"%s\"\n", creds.AccessKeyId)
77+
fmt.Printf("export AWS_ACCESS_KEY_ID=\"%s\"\n", creds.AccessKeyID)
7778
fmt.Printf("export AWS_SECRET_ACCESS_KEY=\"%s\"\n", creds.SecretAccessKey)
7879
fmt.Printf("export AWS_SESSION_TOKEN=\"%s\"\n", creds.SessionToken)
7980
fmt.Printf("export AWS_SECURITY_TOKEN=\"%s\"\n", creds.SessionToken)

0 commit comments

Comments
 (0)