mirror of https://github.com/docker/cli.git
25 lines
542 B
Go
25 lines
542 B
Go
package credentials
|
|
|
|
import (
|
|
exec "golang.org/x/sys/execabs"
|
|
)
|
|
|
|
// DetectDefaultStore return the default credentials store for the platform if
|
|
// no user-defined store is passed, and the store executable is available.
|
|
func DetectDefaultStore(store string) string {
|
|
if store != "" {
|
|
// use user-defined
|
|
return store
|
|
}
|
|
|
|
platformDefault := defaultCredentialsStore()
|
|
if platformDefault == "" {
|
|
return ""
|
|
}
|
|
|
|
if _, err := exec.LookPath(remoteCredentialsPrefix + platformDefault); err != nil {
|
|
return ""
|
|
}
|
|
return platformDefault
|
|
}
|