kv

package
v0.0.0-...-5157a32 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package kv provides an API client for the Vault KVv1 secrets engine.

To use the default KV secrets engine mounted at "/secret", use the DefaultClient:

// List the KV secret keys at the path "/secret/some/nested/path".
kv.DefaultClient.ReadSecret("some/nested/path")
kv.ListSecrets("some/nested/path") // shorthand of the above line

To use a kv secrets engine mounted at a custom path, create a new Client:

// Create a secret at the KV path "/my-kv/some/path".
c := kv.NewClient("/my-kv", nil)
c.WriteSecret("some/path", map[string]interface{}{"foo": "bar"})

See https://www.vaultproject.io/api-docs/secret/kv/kv-v1 for more information on the available endpoints.

Index

Constants

This section is empty.

Variables

View Source
var DefaultClient = NewClient(defaultMountPath, nil)

DefaultClient is a KVv1 API client mounted at the default path in Vault.

Functions

func DeleteSecret

func DeleteSecret(path string) error

DeleteSecret deletes the secret at the specified path using the DefaultClient.

See https://www.vaultproject.io/api/secret/kv/kv-v1#delete-secret.

func ListSecrets

func ListSecrets(path string) ([]string, error)

ListSecrets lists the secret keys at the specified path using the DefaultClient.

See https://www.vaultproject.io/api/secret/kv/kv-v1#list-secrets.

func ReadSecret

func ReadSecret(path string) (map[string]interface{}, error)

ReadSecret reads the secret at the specified path using the DefaultClient.

See https://www.vaultproject.io/api/secret/kv/kv-v1#read-secret.

func WriteSecret

func WriteSecret(path string, data map[string]interface{}) error

WriteSecret creates or updates the secret at the specified path using the DefaultClient.

See https://www.vaultproject.io/api/secret/kv/kv-v1#create-update-secret.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is an API client for the Vault KVv1 secrets engine.

See https://www.vaultproject.io/api-docs/secret/kv/kv-v1#kv-secrets-engine-version-1-api.

func NewClient

func NewClient(path string, client vault.LogicalClient) *Client

NewClient creates a new KVv1 API client for the secrets engine mounted at the given path in Vault.

func (*Client) DeleteSecret

func (c *Client) DeleteSecret(path string) error

DeleteSecret deletes the secret at the specified path.

See https://www.vaultproject.io/api/secret/kv/kv-v1#delete-secret.

func (*Client) ListSecrets

func (c *Client) ListSecrets(path string) ([]string, error)

ListSecrets lists the secret keys at the specified path.

See https://www.vaultproject.io/api/secret/kv/kv-v1#list-secrets.

func (*Client) ReadSecret

func (c *Client) ReadSecret(path string) (map[string]interface{}, error)

ReadSecret reads the secret at the specified path.

See https://www.vaultproject.io/api/secret/kv/kv-v1#read-secret.

func (*Client) WriteSecret

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

WriteSecret creates or updates the secret at the specified path.

See https://www.vaultproject.io/api/secret/kv/kv-v1#create-update-secret.

Jump to

Keyboard shortcuts

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