GODT-1451: Do not check for gnome keyring to allow other implementations of secret-service API. Thanks to @remgodow.

This commit is contained in:
Jakub
2022-01-10 16:45:07 +01:00
committed by Jakub Cuth
parent 63379001e3
commit c920c53243
4 changed files with 13 additions and 15 deletions

View File

@ -28,27 +28,25 @@ import (
)
const (
Pass = "pass-app"
GnomeKeyring = "gnome-keyring"
Pass = "pass-app"
SecretService = "secret-service"
)
func init() { // nolint[noinit]
Helpers = make(map[string]helperConstructor)
Helpers[SecretService] = newSecretServiceHelper
if _, err := exec.LookPath("pass"); err == nil {
Helpers[Pass] = newPassHelper
}
if _, err := exec.LookPath("gnome-keyring"); err == nil {
Helpers[GnomeKeyring] = newGnomeKeyringHelper
}
// If Pass is available, use it by default.
// Otherwise, if GnomeKeyring is available, use it by default.
// Otherwise, if SecretService is available, use it by default.
if _, ok := Helpers[Pass]; ok && isUsable(newPassHelper("")) {
defaultHelper = Pass
} else if _, ok := Helpers[GnomeKeyring]; ok && isUsable(newGnomeKeyringHelper("")) {
defaultHelper = GnomeKeyring
} else if isUsable(newSecretServiceHelper("")) {
defaultHelper = SecretService
}
}
@ -56,7 +54,7 @@ func newPassHelper(string) (credentials.Helper, error) {
return &pass.Pass{}, nil
}
func newGnomeKeyringHelper(string) (credentials.Helper, error) {
func newSecretServiceHelper(string) (credentials.Helper, error) {
return &secretservice.Secretservice{}, nil
}