Skip to content

Commit

Permalink
aws/session: Skip shared config on read errors (#883)
Browse files Browse the repository at this point in the history
Make it skip shared config file if it can't be read for
whatever reason (not exist, permissions, IO error, etc).

Previously files were skipped only if they didn't exist,
but other conditions can prevent them from being read and
same logic should be applicable to them.
  • Loading branch information
redbaron authored and jasdel committed Oct 10, 2016
1 parent 6e6021d commit 9a4f65b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions aws/session/shared_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package session

import (
"fmt"
"os"
"io/ioutil"

"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/aws/credentials"
Expand Down Expand Up @@ -105,12 +105,13 @@ func loadSharedConfigIniFiles(filenames []string) ([]sharedConfigFile, error) {
files := make([]sharedConfigFile, 0, len(filenames))

for _, filename := range filenames {
if _, err := os.Stat(filename); os.IsNotExist(err) {
// Trim files from the list that don't exist.
b, err := ioutil.ReadFile(filename)
if err != nil {
// Skip files which can't be opened and read for whatever reason
continue
}

f, err := ini.Load(filename)
f, err := ini.Load(b)
if err != nil {
return nil, SharedConfigLoadError{Filename: filename}
}
Expand Down

0 comments on commit 9a4f65b

Please sign in to comment.