From 63f9ef1ee270c0b20d2de47fbc0c0e6a03a1a57d Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 17 Jan 2020 17:00:53 -0500 Subject: [PATCH] Add Get method to kvstore --- kvstore.go | 20 ++++++++++++++++++++ types.go | 4 ++++ 2 files changed, 24 insertions(+) diff --git a/kvstore.go b/kvstore.go index 0d15522..7f8eaf2 100644 --- a/kvstore.go +++ b/kvstore.go @@ -62,3 +62,23 @@ func (kv KV) Keys(namespace string) (KVAPI, error) { } 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 +} diff --git a/types.go b/types.go index af01c2a..c65aa99 100644 --- a/types.go +++ b/types.go @@ -676,6 +676,9 @@ type kvResult struct { TeamName string `json:"teamName"` Namespaces []string `json:"namespaces"` 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 @@ -889,6 +892,7 @@ type KV struct { type kvInterface interface { Namespaces() (KVAPI, error) Keys(namespace string) (KVAPI, error) + Get(namespace string, key string) (KVAPI, error) } type keybase interface {