Skip to content

Commit

Permalink
Add check for env var (minio#1008)
Browse files Browse the repository at this point in the history
Added check for documented env var 
MINIO_SHARED_CREDENTIALS_FILE
  • Loading branch information
ektar authored and nitisht committed Jul 15, 2018
1 parent f44ca54 commit 1336e63
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions pkg/credentials/file_minio_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,17 @@ func NewFileMinioClient(filename string, alias string) *Credentials {
// users home directory.
func (p *FileMinioClient) Retrieve() (Value, error) {
if p.filename == "" {
homeDir, err := homedir.Dir()
if err != nil {
return Value{}, err
}
p.filename = filepath.Join(homeDir, ".mc", "config.json")
if runtime.GOOS == "windows" {
p.filename = filepath.Join(homeDir, "mc", "config.json")
if value, ok := os.LookupEnv("MINIO_SHARED_CREDENTIALS_FILE"); ok {
p.filename = value
} else {
homeDir, err := homedir.Dir()
if err != nil {
return Value{}, err
}
p.filename = filepath.Join(homeDir, ".mc", "config.json")
if runtime.GOOS == "windows" {
p.filename = filepath.Join(homeDir, "mc", "config.json")
}
}
}

Expand Down

0 comments on commit 1336e63

Please sign in to comment.