Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotConfigured = errors.New("credentials not configured")
ErrNotConfigured is returned when no credentials are stored for the requested profile.
var ErrReadOnly = errors.New("credential store is read-only")
ErrReadOnly is returned when Set or Delete is called on a read-only store.
Functions ¶
func KeyringServiceName ¶
KeyringServiceName returns the keyring service name for a profile.
Types ¶
type Credentials ¶
type Credentials struct {
APIKey string `json:"apiKey"`
Token string `json:"token"`
AuthMode string `json:"authMode"`
}
Credentials holds the API key, token, and auth mode for a profile.
type EnvStore ¶
type EnvStore struct{}
EnvStore reads credentials from environment variables. It is read-only.
func NewEnvStore ¶
func NewEnvStore() *EnvStore
NewEnvStore creates a new environment-variable-backed credential store.
type FallbackStore ¶
type FallbackStore struct {
// contains filtered or unexported fields
}
FallbackStore tries the primary Store first and falls back to secondary when credentials are not configured.
func NewFallbackStore ¶
func NewFallbackStore(primary, secondary Store) *FallbackStore
NewFallbackStore creates a new fallback chain with the provided primary and secondary stores.
func (*FallbackStore) Delete ¶
func (f *FallbackStore) Delete(profile string) error
func (*FallbackStore) Get ¶
func (f *FallbackStore) Get(profile string) (Credentials, error)
func (*FallbackStore) Set ¶
func (f *FallbackStore) Set(profile string, creds Credentials) error
type KeyringStore ¶
type KeyringStore struct{}
KeyringStore persists credentials in the OS keyring.
func NewKeyringStore ¶
func NewKeyringStore() *KeyringStore
NewKeyringStore creates a new keyring-backed credential store.
func (*KeyringStore) Delete ¶
func (k *KeyringStore) Delete(profile string) error
func (*KeyringStore) Get ¶
func (k *KeyringStore) Get(profile string) (Credentials, error)
func (*KeyringStore) Set ¶
func (k *KeyringStore) Set(profile string, creds Credentials) error
type MemoryStore ¶
type MemoryStore struct {
// contains filtered or unexported fields
}
MemoryStore is an in-memory Store implementation, primarily for testing.
func NewMemoryStore ¶
func NewMemoryStore() *MemoryStore
NewMemoryStore creates a new in-memory credential store.
func (*MemoryStore) Delete ¶
func (m *MemoryStore) Delete(profile string) error
func (*MemoryStore) Get ¶
func (m *MemoryStore) Get(profile string) (Credentials, error)
func (*MemoryStore) Set ¶
func (m *MemoryStore) Set(profile string, creds Credentials) error
type Store ¶
type Store interface {
Get(profile string) (Credentials, error)
Set(profile string, creds Credentials) error
Delete(profile string) error
}
Store defines the interface for credential persistence.