From 4cf1849418874be9d2c2cb4d4b16d6c689c34a35 Mon Sep 17 00:00:00 2001 From: Tycho Andersen Date: Mon, 14 Aug 2017 08:58:19 -0600 Subject: [PATCH] defaultCredentialStore: make this a function In the next patch, we'll use this to implement some logic about which password backend to use. Signed-off-by: Tycho Andersen --- cli/config/credentials/default_store.go | 8 +++++--- cli/config/credentials/default_store_darwin.go | 4 +++- cli/config/credentials/default_store_linux.go | 4 +++- cli/config/credentials/default_store_windows.go | 4 +++- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/cli/config/credentials/default_store.go b/cli/config/credentials/default_store.go index b2cc4df8bc..7a760f1a97 100644 --- a/cli/config/credentials/default_store.go +++ b/cli/config/credentials/default_store.go @@ -7,13 +7,15 @@ import ( // DetectDefaultStore return the default credentials store for the platform if // the store executable is available. func DetectDefaultStore(store string) string { + platformDefault := defaultCredentialsStore() + // user defined or no default for platform - if store != "" || defaultCredentialsStore == "" { + if store != "" || platformDefault == "" { return store } - if _, err := exec.LookPath(remoteCredentialsPrefix + defaultCredentialsStore); err == nil { - return defaultCredentialsStore + if _, err := exec.LookPath(remoteCredentialsPrefix + platformDefault); err == nil { + return platformDefault } return "" } diff --git a/cli/config/credentials/default_store_darwin.go b/cli/config/credentials/default_store_darwin.go index 63e8ed4010..5d42dec622 100644 --- a/cli/config/credentials/default_store_darwin.go +++ b/cli/config/credentials/default_store_darwin.go @@ -1,3 +1,5 @@ package credentials -const defaultCredentialsStore = "osxkeychain" +func defaultCredentialsStore() string { + return "osxkeychain" +} diff --git a/cli/config/credentials/default_store_linux.go b/cli/config/credentials/default_store_linux.go index 864c540f6c..8e51385943 100644 --- a/cli/config/credentials/default_store_linux.go +++ b/cli/config/credentials/default_store_linux.go @@ -1,3 +1,5 @@ package credentials -const defaultCredentialsStore = "secretservice" +func defaultCredentialsStore() string { + return "secretservice" +} diff --git a/cli/config/credentials/default_store_windows.go b/cli/config/credentials/default_store_windows.go index fb6a9745cf..bb799ca61b 100644 --- a/cli/config/credentials/default_store_windows.go +++ b/cli/config/credentials/default_store_windows.go @@ -1,3 +1,5 @@ package credentials -const defaultCredentialsStore = "wincred" +func defaultCredentialsStore() string { + return "wincred" +}