func listPlain(key string, store backend.Store) (backend.KVPairs, error) { data, err := store.List(key) if err != nil { return nil, err } return data, err }
func listEncrypted(key, keyring string, store backend.Store) (backend.KVPairs, error) { var ( passring keyctl.Keyring pkr prompt.PassphraseKeyring ) kr, err := os.Open(secretKeyring) if err != nil { return nil, err } defer kr.Close() data, err := store.List(key) if err != nil { return nil, err } if passring, err = SessionKeyring(); err == nil { pkr = prompt.PassphraseKeyring{Keyring: passring} pkr.Prompt = prompt.NewPrompter(prompt.PassphrasePrompt) } for i, kv := range data { if passring != nil { data[i].Value, err = secconf.DecodeVia(kv.Value, kr, pkr) } else { data[i].Value, err = secconf.Decode(kv.Value, kr) } kr.Seek(0, 0) if err != nil { return nil, err } } return data, err }