secrets

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound indicates that a secret key does not exist.
	ErrNotFound = errors.New("secrets: not found")
	// ErrReadOnly indicates that the selected store does not support writes.
	ErrReadOnly = errors.New("secrets: read-only store")
	// ErrNotConfigured indicates that the selected store is missing required settings.
	ErrNotConfigured = errors.New("secrets: not configured")
	// ErrInvalidKey indicates that a secret key cannot be represented safely.
	ErrInvalidKey = errors.New("secrets: invalid key")
	// ErrInsecureVaultAddress indicates that a Vault address would send secrets over an unsafe channel.
	ErrInsecureVaultAddress = errors.New("secrets: vault address must use https")
	// ErrNotImplemented is kept for compatibility with older releases.
	// Deprecated: VaultStore now returns ErrNotConfigured when setup is incomplete.
	ErrNotImplemented = errors.New("secrets: not implemented")
)

Functions

This section is empty.

Types

type CipherStore

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

CipherStore wraps a Store and encrypts values at rest.

func NewCipherStore

func NewCipherStore(store Store, key []byte) (*CipherStore, error)

NewCipherStore creates a store that encrypts values with AES-GCM.

func (*CipherStore) Delete

func (c *CipherStore) Delete(key string) error

func (*CipherStore) Get

func (c *CipherStore) Get(key string) ([]byte, error)

func (*CipherStore) Set

func (c *CipherStore) Set(key string, value []byte) error

type EnvStore

type EnvStore struct{}

EnvStore provides read-only access to environment variables.

func NewEnvStore

func NewEnvStore() *EnvStore

NewEnvStore creates a new environment-backed secret store.

func (*EnvStore) Delete

func (e *EnvStore) Delete(key string) error

Delete reports that environment-backed stores are read-only.

func (*EnvStore) Get

func (e *EnvStore) Get(key string) ([]byte, error)

Get returns the environment variable value for the provided key.

func (*EnvStore) Set

func (e *EnvStore) Set(key string, value []byte) error

Set reports that environment-backed stores are read-only.

type FallbackStore

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

FallbackStore tries the primary store first, then falls back to secondary.

func NewFallbackStore

func NewFallbackStore(primary, secondary Store) *FallbackStore

NewFallbackStore creates a store that tries primary first, then falls back to secondary.

func (*FallbackStore) Delete

func (f *FallbackStore) Delete(key string) error

func (*FallbackStore) Get

func (f *FallbackStore) Get(key string) ([]byte, error)

func (*FallbackStore) Set

func (f *FallbackStore) Set(key string, value []byte) error

type MemoryStore

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

MemoryStore is a thread-safe in-memory store intended for tests and ephemeral use.

func NewMemoryStore

func NewMemoryStore() *MemoryStore

NewMemoryStore creates a new in-memory store.

func (*MemoryStore) Delete

func (s *MemoryStore) Delete(key string) error

Delete removes a secret from the in-memory store.

func (*MemoryStore) Get

func (s *MemoryStore) Get(key string) ([]byte, error)

Get returns a copy of the stored secret value.

func (*MemoryStore) Set

func (s *MemoryStore) Set(key string, value []byte) error

Set stores a copy of the provided secret value.

type PrefixStore

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

PrefixStore adds a namespace prefix to keys.

func NewPrefixStore

func NewPrefixStore(store Store, prefix string) *PrefixStore

NewPrefixStore wraps a Store and prepends the given prefix to all keys.

func (*PrefixStore) Delete

func (p *PrefixStore) Delete(key string) error

func (*PrefixStore) Get

func (p *PrefixStore) Get(key string) ([]byte, error)

func (*PrefixStore) Set

func (p *PrefixStore) Set(key string, value []byte) error

type Store

type Store interface {
	Set(key string, value []byte) error
	Get(key string) ([]byte, error)
	Delete(key string) error
}

Store is the shared contract for secret backends.

type VaultOption added in v1.2.0

type VaultOption func(*VaultStore)

VaultOption configures a VaultStore.

func WithVaultAddress added in v1.2.0

func WithVaultAddress(addr string) VaultOption

WithVaultAddress sets the Vault base URL.

func WithVaultClient added in v1.2.0

func WithVaultClient(client *http.Client) VaultOption

WithVaultClient sets the HTTP client.

func WithVaultMount added in v1.2.0

func WithVaultMount(mount string) VaultOption

WithVaultMount sets the KV v2 mount name.

func WithVaultToken added in v1.2.0

func WithVaultToken(token string) VaultOption

WithVaultToken sets the Vault token.

type VaultStore

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

VaultStore stores secrets in a HashiCorp Vault KV v2 mount.

func NewVaultStore

func NewVaultStore(opts ...VaultOption) *VaultStore

NewVaultStore creates a Vault-backed store.

func (*VaultStore) Delete

func (v *VaultStore) Delete(key string) error

Delete removes a secret from Vault.

func (*VaultStore) Get

func (v *VaultStore) Get(key string) ([]byte, error)

Get reads a secret value from Vault.

func (*VaultStore) Set

func (v *VaultStore) Set(key string, value []byte) error

Set stores a secret value in Vault.

Jump to

Keyboard shortcuts

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