Merge pull request #4262 from thaJeztah/no_lookpath

cli/config/credentials: skip unneeded exec.LookPath()
This commit is contained in:
Sebastiaan van Stijn 2023-05-16 18:10:50 +01:00 committed by GitHub
commit 761d973656
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 8 deletions

View File

@ -5,17 +5,20 @@ import (
)
// DetectDefaultStore return the default credentials store for the platform if
// the store executable is available.
// no user-defined store is passed, and the store executable is available.
func DetectDefaultStore(store string) string {
platformDefault := defaultCredentialsStore()
// user defined or no default for platform
if store != "" || platformDefault == "" {
if store != "" {
// use user-defined
return store
}
if _, err := exec.LookPath(remoteCredentialsPrefix + platformDefault); err == nil {
return platformDefault
platformDefault := defaultCredentialsStore()
if platformDefault == "" {
return ""
}
return ""
if _, err := exec.LookPath(remoteCredentialsPrefix + platformDefault); err != nil {
return ""
}
return platformDefault
}