defaultCredentialStore: make this a function

In the next patch, we'll use this to implement some logic about which
password backend to use.

Signed-off-by: Tycho Andersen <tycho@docker.com>
master
Tycho Andersen 2017-08-14 08:58:19 -06:00
parent 10e292dbab
commit 4cf1849418
4 changed files with 14 additions and 6 deletions

View File

@ -7,13 +7,15 @@ import (
// DetectDefaultStore return the default credentials store for the platform if
// the store executable is available.
func DetectDefaultStore(store string) string {
platformDefault := defaultCredentialsStore()
// user defined or no default for platform
if store != "" || defaultCredentialsStore == "" {
if store != "" || platformDefault == "" {
return store
}
if _, err := exec.LookPath(remoteCredentialsPrefix + defaultCredentialsStore); err == nil {
return defaultCredentialsStore
if _, err := exec.LookPath(remoteCredentialsPrefix + platformDefault); err == nil {
return platformDefault
}
return ""
}

View File

@ -1,3 +1,5 @@
package credentials
const defaultCredentialsStore = "osxkeychain"
func defaultCredentialsStore() string {
return "osxkeychain"
}

View File

@ -1,3 +1,5 @@
package credentials
const defaultCredentialsStore = "secretservice"
func defaultCredentialsStore() string {
return "secretservice"
}

View File

@ -1,3 +1,5 @@
package credentials
const defaultCredentialsStore = "wincred"
func defaultCredentialsStore() string {
return "wincred"
}