Skip to content

Commit 761d973

Browse files
authored
Merge pull request #4262 from thaJeztah/no_lookpath
cli/config/credentials: skip unneeded exec.LookPath()
2 parents 935df5a + ce11b28 commit 761d973

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

cli/config/credentials/default_store.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,20 @@ import (
55
)
66

77
// DetectDefaultStore return the default credentials store for the platform if
8-
// the store executable is available.
8+
// no user-defined store is passed, and the store executable is available.
99
func DetectDefaultStore(store string) string {
10-
platformDefault := defaultCredentialsStore()
11-
12-
// user defined or no default for platform
13-
if store != "" || platformDefault == "" {
10+
if store != "" {
11+
// use user-defined
1412
return store
1513
}
1614

17-
if _, err := exec.LookPath(remoteCredentialsPrefix + platformDefault); err == nil {
18-
return platformDefault
15+
platformDefault := defaultCredentialsStore()
16+
if platformDefault == "" {
17+
return ""
18+
}
19+
20+
if _, err := exec.LookPath(remoteCredentialsPrefix + platformDefault); err != nil {
21+
return ""
1922
}
20-
return ""
23+
return platformDefault
2124
}

0 commit comments

Comments
 (0)