2016-12-25 14:31:52 -05:00
|
|
|
package credentials
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os/exec"
|
|
|
|
)
|
|
|
|
|
2017-06-21 16:47:06 -04:00
|
|
|
// DetectDefaultStore return the default credentials store for the platform if
|
|
|
|
// the store executable is available.
|
|
|
|
func DetectDefaultStore(store string) string {
|
2017-08-14 10:58:19 -04:00
|
|
|
platformDefault := defaultCredentialsStore()
|
|
|
|
|
2017-06-21 16:47:06 -04:00
|
|
|
// user defined or no default for platform
|
2017-08-14 10:58:19 -04:00
|
|
|
if store != "" || platformDefault == "" {
|
2017-06-21 16:47:06 -04:00
|
|
|
return store
|
2016-12-25 14:31:52 -05:00
|
|
|
}
|
|
|
|
|
2017-08-14 10:58:19 -04:00
|
|
|
if _, err := exec.LookPath(remoteCredentialsPrefix + platformDefault); err == nil {
|
|
|
|
return platformDefault
|
2016-12-25 14:31:52 -05:00
|
|
|
}
|
2017-06-21 16:47:06 -04:00
|
|
|
return ""
|
2016-12-25 14:31:52 -05:00
|
|
|
}
|