aboutsummaryrefslogtreecommitdiff
path: root/vault/simple_client.go
diff options
context:
space:
mode:
Diffstat (limited to 'vault/simple_client.go')
-rw-r--r--vault/simple_client.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/vault/simple_client.go b/vault/simple_client.go
index 4ceb4b5..2bef0a6 100644
--- a/vault/simple_client.go
+++ b/vault/simple_client.go
@@ -55,6 +55,27 @@ func GetVaultKeyStruct(path string, out interface{}) error {
55 return nil 55 return nil
56} 56}
57 57
58// GetVaultApiKey fetches a JSON k/v value from Vault. The JSON document
59// must have the format: { "key": "value" }
60func GetVaultApiKey(path string) (string, error) {
61 s, err := loginAndRead(fmt.Sprintf("kv/data/%s", path))
62 if err != nil {
63 return "", err
64 }
65
66 ret := struct {
67 Key string `json:"key"`
68 }{}
69 if err = mapstructure.Decode(s.Data["data"], &ret); err != nil {
70 return "", err
71 }
72
73 return ret.Key, nil
74}
75
76// GetVaultKey fetches a JSON k/v value from vault. The JSON document
77// must have the format:
78// { "username": "username", "password": "password" }
58func GetVaultKey(path string) (Credential, error) { 79func GetVaultKey(path string) (Credential, error) {
59 s, err := loginAndRead(fmt.Sprintf("kv/data/%s", path)) 80 s, err := loginAndRead(fmt.Sprintf("kv/data/%s", path))
60 if err != nil { 81 if err != nil {