diff --git a/config.go b/config.go index 0526926..8e34b80 100644 --- a/config.go +++ b/config.go @@ -1,5 +1,6 @@ package keyring +// Config contains configuration for keyring type Config struct { // AllowedBackends is a whitelist of backend providers that can be used. Nil means all available. AllowedBackends []BackendType diff --git a/keychain.go b/keychain.go index bf28a57..96fd9e3 100644 --- a/keychain.go +++ b/keychain.go @@ -209,10 +209,10 @@ func (k *keychain) createOrOpen() (gokeychain.Keychain, error) { if err == nil { debugf("Keychain status returned nil, keychain exists") return kc, nil - } else { - debugf("Keychain status returned error: %v", err) } + debugf("Keychain status returned error: %v", err) + if err != gokeychain.ErrorNoSuchKeychain { return gokeychain.Keychain{}, err } diff --git a/keyring.go b/keyring.go index 631d228..1fb3f03 100644 --- a/keyring.go +++ b/keyring.go @@ -8,6 +8,9 @@ import ( "log" ) +// A BackendType is an identifier for a credential storage service +type BackendType string + // All currently supported secure storage backends const ( InvalidBackend BackendType = "invalid" @@ -34,8 +37,6 @@ var backendOrder = []BackendType{ FileBackend, } -type BackendType string - var supportedBackends = map[BackendType]opener{} // AvailableBackends provides a slice of all available backend keys on the current OS @@ -99,10 +100,10 @@ type Keyring interface { var ErrNoAvailImpl = errors.New("Specified keyring backend not available") // ErrKeyNotFound is returned by Keyring Get when the item is not on the keyring -var ErrKeyNotFound = errors.New("The specified item could not be found in the keyring.") +var ErrKeyNotFound = errors.New("The specified item could not be found in the keyring") var ( - // Whether to print debugging output + // Debug specifies whether to print debugging output Debug bool ) diff --git a/prompt.go b/prompt.go index 936d836..d5da409 100644 --- a/prompt.go +++ b/prompt.go @@ -7,6 +7,7 @@ import ( "golang.org/x/crypto/ssh/terminal" ) +// PromptFunc is a function used to prompt the user for a password type PromptFunc func(string) (string, error) func terminalPrompt(prompt string) (string, error) {