Skip to content

Commit

Permalink
use AWS_CONFIG_FILE if defined #80
Browse files Browse the repository at this point in the history
  • Loading branch information
iann0036 committed Jul 17, 2024
1 parent 36143ac commit b444dec
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions iamlivecore/csm.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,14 @@ func setConfigKey(filename, section, line string, unset bool) error {
}

func setINIConfigAndFileFlush() {
cfgfilepath := "~/.aws/config"
if os.Getenv("AWS_CONFIG_FILE") != "" {
cfgfilepath = os.Getenv("AWS_CONFIG_FILE")
}

// set ini
if *setiniFlag {
cfgfile, err := homedir.Expand("~/.aws/config")
cfgfile, err := homedir.Expand(cfgfilepath)
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -119,7 +124,7 @@ func setINIConfigAndFileFlush() {
if s == syscall.SIGINT || s == syscall.SIGTERM || s == syscall.SIGQUIT {
if *setiniFlag {
// revert ini
cfgfile, err := homedir.Expand("~/.aws/config") // need to redeclare
cfgfile, err := homedir.Expand(cfgfilepath) // need to redeclare
if err != nil {
os.Exit(1)
}
Expand Down

0 comments on commit b444dec

Please sign in to comment.