Documentation
¶
Overview ¶
Package credential retrieves provider credentials without putting secrets in application configuration, sessions, logs, or events.
Index ¶
Constants ¶
const APIKeyEnv = "API_KEY"
APIKeyEnv is the provider-neutral API key variable used by the application.
Variables ¶
var ErrNotFound = errors.New("coding credential: credential not found")
ErrNotFound means no usable credential is available for a provider.
Functions ¶
This section is empty.
Types ¶
type Credential ¶
type Credential struct {
// contains filtered or unexported fields
}
Credential contains one provider API key. Its formatting is always redacted; callers must explicitly request the key at the provider boundary.
func (Credential) APIKey ¶
func (c Credential) APIKey() string
APIKey returns the credential value for immediate provider construction.
func (Credential) Format ¶
func (Credential) Format(state fmt.State, _ rune)
Format redacts the credential for every fmt verb, including %#v.
func (Credential) MarshalJSON ¶
func (Credential) MarshalJSON() ([]byte, error)
MarshalJSON prevents reflective serialization from exposing internal credential representation.
type EnvironmentStore ¶
type EnvironmentStore struct {
// contains filtered or unexported fields
}
EnvironmentStore reads provider API keys from an injected environment.
func NewEnvironmentStore ¶
func NewEnvironmentStore(lookup LookupEnv) (*EnvironmentStore, error)
NewEnvironmentStore returns an environment-backed Store.
func (*EnvironmentStore) Get ¶
func (s *EnvironmentStore) Get(ctx context.Context, provider ai.Provider) (Credential, error)
Get implements Store.
type MissingError ¶
MissingError identifies the provider and non-secret environment variable that was checked.
func (*MissingError) Unwrap ¶
func (*MissingError) Unwrap() error
Unwrap makes MissingError match ErrNotFound.