vaultkv

package module
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 28, 2021 License: MIT Imports: 4 Imported by: 4

README

Go Report Card GoDoc Build Status Coverage Status

Package vaultkv

Package vaultkv provides version agnostic methods for read, write and list of secrets from @hashicorp Vault's KV secret engines

Replaces: github.com/postfinance/vault/kv

Requirements

Requires list and read privileges on /sys/mounts

Documentation

Overview

Package vaultkv provides version agnostic methods for read, write and list of secrets from @hashicorp Vault's KV secret engines

Index

Constants

View Source
const (
	ReadPrefix  = "data"
	WritePrefix = ReadPrefix
	ListPrefix  = "metadata"
)

Constants

Variables

This section is empty.

Functions

func FixPath

func FixPath(path, mount, prefix string) string

FixPath inserts the API prefix for v1 style path secret/foo -> secret/data/foo secret/data/foo -> secret/data/foo presumes a valid path

Types

type Client

type Client struct {
	Version int
	Mount   string
	// contains filtered or unexported fields
}

Client represents a KV client

func New

func New(c *api.Client, p string) (*Client, error)

New creates a new kv.Client with the Vault client c and a path p long enough to determine the mount path of the engine p = secret/ -> K/V engine mount path secret/ p = secret -> error p = /secret -> error

func (*Client) Client

func (c *Client) Client() *api.Client

Client returns a Vault *api.Client

func (*Client) List

func (c *Client) List(p string) ([]string, error)

List secrets from a K/V version 1 or 2

func (*Client) Read

func (c *Client) Read(p string) (map[string]interface{}, error)

Read a secret from a K/V version 1 or 2

func (*Client) SetToken

func (c *Client) SetToken(v string)

SetToken sets the token directly. This won't perform any auth verification, it simply sets the token properly for future requests.

func (*Client) Write

func (c *Client) Write(p string, data map[string]interface{}) error

Write a secret to a K/V version 1 or 2

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL