kv

package
v0.19.2 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package kv represents Vault key-value pairs.

Index

Constants

View Source
const (

	// ErrNotFound is the error returned when secret does not exist.
	ErrNotFound = "secret not found"
)

Variables

This section is empty.

Functions

func IsNotFound

func IsNotFound(err error) bool

IsNotFound returns whether given error is a "Not Found" error or not.

Types

type ApplyOption

type ApplyOption func(current, desired *Secret) error

An ApplyOption is called before patching the current secret to match the desired secret. ApplyOptions are not called if no current object exists.

func AllowUpdateIf

func AllowUpdateIf(fn func(current, desired *Secret) bool) ApplyOption

AllowUpdateIf will only update the current object if the supplied fn returns true. An error that satisfies IsNotAllowed will be returned if the supplied function returns false. Creation of a desired object that does not currently exist is always allowed.

type LogicalClient

type LogicalClient interface {
	Read(path string) (*api.Secret, error)
	Write(path string, data map[string]any) (*api.Secret, error)
	Delete(path string) (*api.Secret, error)
}

LogicalClient is a client to perform logical backend operations on Vault.

type Secret

type Secret struct {
	CustomMeta map[string]string
	Data       map[string]string
	// contains filtered or unexported fields
}

Secret is a Vault KV secret.

func NewSecret

func NewSecret(data map[string]string, meta map[string]string) *Secret

NewSecret returns a new Secret.

func (*Secret) AddData

func (kv *Secret) AddData(key string, val string)

AddData adds supplied key value as data.

func (*Secret) AddMetadata

func (kv *Secret) AddMetadata(key string, val string)

AddMetadata adds supplied key value as metadata.

type V1Client

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

V1Client is a Vault KV V1 Secrets Engine client. https://www.vaultproject.io/api-docs/secret/kv/kv-v1

func NewV1Client

func NewV1Client(logical LogicalClient, mountPath string) *V1Client

NewV1Client returns a new V1Client.

func (*V1Client) Apply

func (c *V1Client) Apply(path string, secret *Secret, ao ...ApplyOption) error

Apply applies given Secret at path by patching its Data and setting provided custom metadata.

func (*V1Client) Delete

func (c *V1Client) Delete(path string) error

Delete deletes Secret at the given path.

func (*V1Client) Get

func (c *V1Client) Get(path string, secret *Secret) error

Get returns a Secret at a given path.

type V2Client

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

V2Client is a Vault KV V2 Secrets Engine client. https://www.vaultproject.io/api/secret/kv/kv-v2

func NewV2Client

func NewV2Client(logical LogicalClient, mountPath string) *V2Client

NewV2Client returns a new V2Client.

func (*V2Client) Apply

func (c *V2Client) Apply(path string, secret *Secret, ao ...ApplyOption) error

Apply applies given Secret at path by patching its Data and setting provided custom metadata.

func (*V2Client) Delete

func (c *V2Client) Delete(path string) error

Delete deletes Secret at the given path.

func (*V2Client) Get

func (c *V2Client) Get(path string, secret *Secret) error

Get returns a Secret at a given path.

Directories

Path Synopsis
Package fake is a fake Vault LogicalClient.
Package fake is a fake Vault LogicalClient.

Jump to

Keyboard shortcuts

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