2017-11-29 22:20:27 +00:00
|
|
|
package shareddefaults
|
|
|
|
|
|
|
|
import (
|
2023-08-17 09:51:25 +00:00
|
|
|
"os/user"
|
2017-11-29 22:20:27 +00:00
|
|
|
"path/filepath"
|
|
|
|
)
|
|
|
|
|
|
|
|
// SharedCredentialsFilename returns the SDK's default file path
|
|
|
|
// for the shared credentials file.
|
|
|
|
//
|
|
|
|
// Builds the shared config file path based on the OS's platform.
|
|
|
|
//
|
|
|
|
// - Linux/Unix: $HOME/.aws/credentials
|
|
|
|
// - Windows: %USERPROFILE%\.aws\credentials
|
|
|
|
func SharedCredentialsFilename() string {
|
|
|
|
return filepath.Join(UserHomeDir(), ".aws", "credentials")
|
|
|
|
}
|
|
|
|
|
|
|
|
// SharedConfigFilename returns the SDK's default file path for
|
|
|
|
// the shared config file.
|
|
|
|
//
|
|
|
|
// Builds the shared config file path based on the OS's platform.
|
|
|
|
//
|
|
|
|
// - Linux/Unix: $HOME/.aws/config
|
|
|
|
// - Windows: %USERPROFILE%\.aws\config
|
|
|
|
func SharedConfigFilename() string {
|
|
|
|
return filepath.Join(UserHomeDir(), ".aws", "config")
|
|
|
|
}
|
|
|
|
|
|
|
|
// UserHomeDir returns the home directory for the user the process is
|
|
|
|
// running under.
|
|
|
|
func UserHomeDir() string {
|
2023-08-17 09:51:25 +00:00
|
|
|
var home string
|
|
|
|
|
|
|
|
home = userHomeDir()
|
|
|
|
if len(home) > 0 {
|
|
|
|
return home
|
|
|
|
}
|
|
|
|
|
|
|
|
currUser, _ := user.Current()
|
|
|
|
if currUser != nil {
|
|
|
|
home = currUser.HomeDir
|
2017-11-29 22:20:27 +00:00
|
|
|
}
|
|
|
|
|
2023-08-17 09:51:25 +00:00
|
|
|
return home
|
2017-11-29 22:20:27 +00:00
|
|
|
}
|