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