@@ -2,13 +2,14 @@ package vault
2
2
3
3
import (
4
4
"encoding/json"
5
- "github.com/hashicorp/vault/api"
6
5
"io/ioutil"
7
6
"net/url"
7
+
8
+ "github.com/hashicorp/vault/api"
8
9
)
9
10
10
11
type Client struct {
11
- api.Client
12
+ * api.Client
12
13
}
13
14
14
15
type TLSConfig struct {
@@ -29,19 +30,22 @@ func WithCaPath(path string) *TLSConfig {
29
30
30
31
func NewClient (addr string , tlsConf * TLSConfig , opts ... ClientOpts ) (* Client , error ) {
31
32
conf := api .DefaultConfig ()
33
+
32
34
conf .Address = addr
35
+
33
36
if tlsConf != nil {
34
37
if err := conf .ConfigureTLS (tlsConf .TLSConfig ); err != nil {
35
38
return nil , err
36
39
}
37
-
38
40
}
39
41
40
42
vaultClient , err := api .NewClient (conf )
41
43
if err != nil {
42
44
return nil , err
43
45
}
44
- client := & Client {Client : * vaultClient }
46
+
47
+ client := & Client {Client : vaultClient }
48
+
45
49
for _ , opt := range opts {
46
50
err := opt (client )
47
51
if err != nil {
@@ -82,21 +86,22 @@ func (c *Client) Request(method string, path []string, body interface{}, paramet
82
86
return err
83
87
}
84
88
}
89
+
85
90
return nil
86
91
}
87
92
88
93
func (c * Client ) Read (path []string , parameters url.Values , response interface {}) error {
89
94
return c .Request ("GET" , path , nil , parameters , response )
90
95
}
91
96
92
- func (c * Client ) Write (path []string , body interface {} , response interface {}) error {
97
+ func (c * Client ) Write (path []string , body , response interface {}) error {
93
98
return c .Request ("POST" , path , body , nil , response )
94
99
}
95
100
96
- func (c * Client ) Delete (path []string , body interface {} , response interface {}) error {
101
+ func (c * Client ) Delete (path []string , body , response interface {}) error {
97
102
return c .Request ("DELETE" , path , body , nil , response )
98
103
}
99
104
100
- func (c * Client ) List (path []string , body interface {} , response interface {}) error {
105
+ func (c * Client ) List (path []string , body , response interface {}) error {
101
106
return c .Request ("LIST" , path , body , nil , response )
102
107
}
0 commit comments