Documentation
¶
Index ¶
- Constants
- Variables
- type EnvStore
- type MockStore
- func (m *MockStore) Delete(service, key string) error
- func (m *MockStore) Get(service, key string) (string, error)
- func (m *MockStore) Set(service, key, value string) error
- func (m *MockStore) WithData(service, key, value string) *MockStore
- func (m *MockStore) WithDeleteError(err error) *MockStore
- func (m *MockStore) WithGetError(err error) *MockStore
- func (m *MockStore) WithSetError(err error) *MockStore
- type Store
- type SystemStore
Constants ¶
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 ¶
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 ¶
NewEnvStore creates a new EnvStore wrapping the given 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) WithDeleteError ¶
WithDeleteError configures the mock to return an error on Delete calls.
func (*MockStore) WithGetError ¶
WithGetError configures the mock to return an error on Get calls.
func (*MockStore) WithSetError ¶
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.