defaultCredentialsStore() on Linux does an exec.LookPath() for "pass", but if a custom credential-store is passed to DetectDefaultStore, the result of that won't be used. This patch changes the logic to return early if a custom credential-store is passed. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
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
|
|
}
|