apply options on newly added keyring types (#5404)

This commit is contained in:
Austin Abell 2019-12-13 06:21:49 -05:00 committed by Alessio Treglia
parent 0e28da23e7
commit d7b0f4b9b4
2 changed files with 5 additions and 5 deletions

View File

@ -56,11 +56,11 @@ func NewKeyringFromDir(rootDir string, input io.Reader, opts ...keys.KeybaseOpti
keyringBackend := viper.GetString(flags.FlagKeyringBackend) keyringBackend := viper.GetString(flags.FlagKeyringBackend)
switch keyringBackend { switch keyringBackend {
case flags.KeyringBackendTest: case flags.KeyringBackendTest:
return keys.NewTestKeyring(sdk.GetConfig().GetKeyringServiceName(), rootDir) return keys.NewTestKeyring(sdk.GetConfig().GetKeyringServiceName(), rootDir, opts...)
case flags.KeyringBackendFile: case flags.KeyringBackendFile:
return keys.NewKeyringFile(sdk.GetConfig().GetKeyringServiceName(), rootDir, input) return keys.NewKeyringFile(sdk.GetConfig().GetKeyringServiceName(), rootDir, input, opts...)
case flags.KeyringBackendOS: case flags.KeyringBackendOS:
return keys.NewKeyring(sdk.GetConfig().GetKeyringServiceName(), rootDir, input) return keys.NewKeyring(sdk.GetConfig().GetKeyringServiceName(), rootDir, input, opts...)
} }
return nil, fmt.Errorf("unknown keyring backend %q", keyringBackend) return nil, fmt.Errorf("unknown keyring backend %q", keyringBackend)
} }

View File

@ -56,13 +56,13 @@ func NewKeyring(
} }
// NewKeyringFile creates a new instance of an encrypted file-backed keyring. // NewKeyringFile creates a new instance of an encrypted file-backed keyring.
func NewKeyringFile(name string, dir string, userInput io.Reader) (Keybase, error) { func NewKeyringFile(name string, dir string, userInput io.Reader, opts ...KeybaseOption) (Keybase, error) {
db, err := keyring.Open(newFileBackendKeyringConfig(name, dir, userInput)) db, err := keyring.Open(newFileBackendKeyringConfig(name, dir, userInput))
if err != nil { if err != nil {
return nil, err return nil, err
} }
return newKeyringKeybase(db), nil return newKeyringKeybase(db, opts...), nil
} }
// NewTestKeyring creates a new instance of an on-disk keyring for // NewTestKeyring creates a new instance of an on-disk keyring for