Skip to content

Commit

Permalink
fix(Keychain) Log interesting keychain errors to help with fault finding
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfeidau committed Nov 21, 2017
1 parent 9a1ca17 commit 32b5351
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 9 additions & 5 deletions helper/credentials/credentials.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package credentials

import "errors"
import (
"errors"
)

// CurrentHelper the currently configured credentials helper
var CurrentHelper Helper = &defaultHelper{}
var (
// CurrentHelper the currently configured credentials helper
CurrentHelper Helper = &defaultHelper{}

// ErrCredentialsNotFound returned when the credential can't be located in the native store.
var ErrCredentialsNotFound = errors.New("credentials not found in native keychain")
// ErrCredentialsNotFound returned when the credential can't be located in the native store.
ErrCredentialsNotFound = errors.New("credentials not found in native keychain")
)

// Credentials holds the information shared between saml2aws and the credentials store.
type Credentials struct {
Expand Down
2 changes: 2 additions & 0 deletions helper/osxkeychain/osxkeychain_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,13 @@ func (h Osxkeychain) Get(serverURL string) (string, string, error) {
if errMsg != nil {
defer C.free(unsafe.Pointer(errMsg))
goMsg := C.GoString(errMsg)

if goMsg == errCredentialsNotFound {
logger.WithField("goMsg", goMsg).Debug("Get credentials")
return "", "", credentials.ErrCredentialsNotFound
}

logger.WithField("goMsg", goMsg).Error("keychain Get returned error")
return "", "", errors.New(goMsg)
}

Expand Down

0 comments on commit 32b5351

Please sign in to comment.