1
0
mirror of https://github.com/docker/cli.git synced 2026-01-18 08:21:31 +03:00

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>
Upstream-commit: 4cf1849418
Component: cli
This commit is contained in:
Tycho Andersen
2017-08-14 08:58:19 -06:00
parent cdbfcd2c1d
commit 315e815656
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"
}