Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
32 lines (26 sloc) 859 Bytes
package vaku
import "fmt"
// PathWrite takes in a PathInput and data to written to that path. It then
// calls the native vault write with that data at the specified path.
func (c *Client) PathWrite(i *PathInput, d map[string]interface{}) error {
var err error
// Initialize the input
i.opType = "write"
err = c.InitPathInput(i)
if err != nil {
return fmt.Errorf("failed to init write path %s: %w", i.Path, err)
}
// V2 mounts nest the actual data in another map[string]interface{}
// https://github.com/hashicorp/vault/blob/69b1cae9e252e9f2f8394675f8df5cd9dca8f5de/command/kv_put.go#L130-L142
if i.mountVersion == "2" {
d = map[string]interface{}{
"data": d,
}
}
// Do the actual write
_, err = c.Logical().Write(i.opPath, d)
if err != nil {
return fmt.Errorf("failed to write secret to %s: %w", i.opPath, err)
}
return err
}
You can’t perform that action at this time.