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>
This commit is contained in:
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 // DetectDefaultStore return the default credentials store for the platform if
// the store executable is available. // the store executable is available.
func DetectDefaultStore(store string) string { func DetectDefaultStore(store string) string {
platformDefault := defaultCredentialsStore()
// user defined or no default for platform // user defined or no default for platform
if store != "" || defaultCredentialsStore == "" { if store != "" || platformDefault == "" {
return store return store
} }
if _, err := exec.LookPath(remoteCredentialsPrefix + defaultCredentialsStore); err == nil { if _, err := exec.LookPath(remoteCredentialsPrefix + platformDefault); err == nil {
return defaultCredentialsStore return platformDefault
} }
return "" return ""
} }

View File

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

View File

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

View File

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