Add Get method to kvstore

This commit is contained in:
Sam
2020-01-17 17:00:53 -05:00
parent 14c7ec6cec
commit 63f9ef1ee2
2 changed files with 24 additions and 0 deletions

View File

@ -62,3 +62,23 @@ func (kv KV) Keys(namespace string) (KVAPI, error) {
} }
return r, nil return r, nil
} }
// Get returns an entry
func (kv KV) Get(namespace string, key string) (KVAPI, error) {
m := KVAPI{
Params: &kvParams{},
}
m.Params.Options = kvOptions{
Team: kv.Team,
Namespace: namespace,
EntryKey: key,
}
m.Method = "get"
r, err := kvAPIOut(kv.keybase, m)
if err != nil {
return r, err
}
return r, nil
}

View File

@ -676,6 +676,9 @@ type kvResult struct {
TeamName string `json:"teamName"` TeamName string `json:"teamName"`
Namespaces []string `json:"namespaces"` Namespaces []string `json:"namespaces"`
EntryKeys []entryKey `json:"entryKeys"` EntryKeys []entryKey `json:"entryKeys"`
EntryKey string `json:"entryKey"`
EntryValue string `json:"entryValue"`
Revision int `json:"revision"`
} }
// UserAPI holds information received from the user/lookup api // UserAPI holds information received from the user/lookup api
@ -889,6 +892,7 @@ type KV struct {
type kvInterface interface { type kvInterface interface {
Namespaces() (KVAPI, error) Namespaces() (KVAPI, error)
Keys(namespace string) (KVAPI, error) Keys(namespace string) (KVAPI, error)
Get(namespace string, key string) (KVAPI, error)
} }
type keybase interface { type keybase interface {