adding a write bytes method (#7611)

This commit is contained in:
Connor Poole 2019-11-08 01:54:05 +00:00 committed by Brian Kassouf
parent d3a7e6e205
commit 2e367c5418
2 changed files with 13 additions and 1 deletions

View File

@ -134,9 +134,20 @@ func (c *Logical) Write(path string, data map[string]interface{}) (*Secret, erro
return nil, err
}
return c.write(path, r)
}
func (c *Logical) WriteBytes(path string, data []byte) (*Secret, error) {
r := c.c.NewRequest("PUT", "/v1/"+path)
r.BodyBytes = data
return c.write(path, r)
}
func (c *Logical) write(path string, request *Request) (*Secret, error) {
ctx, cancelFunc := context.WithCancel(context.Background())
defer cancelFunc()
resp, err := c.c.RawRequestWithContext(ctx, r)
resp, err := c.c.RawRequestWithContext(ctx, request)
if resp != nil {
defer resp.Body.Close()
}

1
go.mod
View File

@ -51,6 +51,7 @@ require (
github.com/google/go-metrics-stackdriver v0.0.0-20190816035513-b52628e82e2a
github.com/hashicorp/consul-template v0.22.0
github.com/hashicorp/consul/api v1.1.0
github.com/hashicorp/consul/api v1.0.1
github.com/hashicorp/errwrap v1.0.0
github.com/hashicorp/go-cleanhttp v0.5.1
github.com/hashicorp/go-gcp-common v0.5.0