keyring

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ServiceName is the keyring service name for storing secrets.
	// Uses reverse domain notation for proper namespacing.
	ServiceName = "com.public.pub"

	// KeySecretKey is the keyring key for the API secret key.
	KeySecretKey = "secret_key"

	// EnvSecretKey is the environment variable name for the secret key.
	// When set, it overrides keyring lookups for CI/headless environments.
	EnvSecretKey = "PUB_SECRET_KEY"
)

Variables

View Source
var ErrNotFound = errors.New("secret not found")

ErrNotFound is returned when a secret is not found in the keyring.

Functions

This section is empty.

Types

type EnvStore

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

EnvStore wraps another Store and checks environment variables first. This enables CI/headless environments to provide credentials via env vars.

func NewEnvStore

func NewEnvStore(underlying Store) *EnvStore

NewEnvStore creates a new EnvStore wrapping the given store.

func (*EnvStore) Delete

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

Delete removes a secret from the underlying store.

func (*EnvStore) Get

func (e *EnvStore) Get(service, key string) (string, error)

Get retrieves a secret, checking env var first for secret_key lookups.

func (*EnvStore) Set

func (e *EnvStore) Set(service, key, value string) error

Set stores a secret in the underlying store.

type MockStore

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

MockStore implements Store for testing. It stores secrets in memory and can be configured to return errors for testing error handling.

func NewMockStore

func NewMockStore() *MockStore

NewMockStore creates a new mock keyring store for testing.

func (*MockStore) Delete

func (m *MockStore) Delete(service, key string) error

Delete removes a secret from the mock store.

func (*MockStore) Get

func (m *MockStore) Get(service, key string) (string, error)

Get retrieves a secret from the mock store.

func (*MockStore) Set

func (m *MockStore) Set(service, key, value string) error

Set stores a secret in the mock store.

func (*MockStore) WithData

func (m *MockStore) WithData(service, key, value string) *MockStore

WithData pre-populates the mock store with a secret.

func (*MockStore) WithDeleteError

func (m *MockStore) WithDeleteError(err error) *MockStore

WithDeleteError configures the mock to return an error on Delete calls.

func (*MockStore) WithGetError

func (m *MockStore) WithGetError(err error) *MockStore

WithGetError configures the mock to return an error on Get calls.

func (*MockStore) WithSetError

func (m *MockStore) WithSetError(err error) *MockStore

WithSetError configures the mock to return an error on Set calls.

type Store

type Store interface {
	Get(service, key string) (string, error)
	Set(service, key, value string) error
	Delete(service, key string) error
}

Store provides an interface for secure secret storage.

type SystemStore

type SystemStore struct{}

SystemStore implements Store using the system keyring.

func NewSystemStore

func NewSystemStore() *SystemStore

NewSystemStore creates a new system keyring store.

func (*SystemStore) Delete

func (s *SystemStore) Delete(service, key string) error

Delete removes a secret from the system keyring.

func (*SystemStore) Get

func (s *SystemStore) Get(service, key string) (string, error)

Get retrieves a secret from the system keyring.

func (*SystemStore) Set

func (s *SystemStore) Set(service, key, value string) error

Set stores a secret in the system keyring.

Jump to

Keyboard shortcuts

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