Documentation
¶
Overview ¶
Package provider resolves effective third-party API keys at lookup time. Precedence, first match wins:
- DB override (settings table, set via the Settings UI)
- Baked-in default from config.DefaultTMDBKey / DefaultTraktClientID
- Empty string — callers should treat this as "no key configured" and return a 503-level error.
The DB-override mechanism lets operators rotate a leaked or rate- limited baked key without rebuilding the image. The baked default is never returned through any API; the Settings UI shows only a redacted preview for overrides.
Index ¶
- Constants
- type Resolver
- func (r *Resolver) ClearOverride(ctx context.Context, name string) error
- func (r *Resolver) EffectiveKey(ctx context.Context, name string) (string, Source, error)
- func (r *Resolver) HasOverride(ctx context.Context, name string) (bool, error)
- func (r *Resolver) Preview(ctx context.Context, name string) (string, Source, error)
- func (r *Resolver) SetOverride(ctx context.Context, name, value string) error
- type Source
- type Store
Constants ¶
const ( TMDB = "tmdb" Trakt = "trakt" )
Provider identifiers — used as DB keys in the settings table and as API path segments.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver reads and writes provider API key overrides in the settings table and falls back to the ldflag-baked defaults when no override is set.
func NewResolver ¶
NewResolver constructs a Resolver backed by the given settings store.
func (*Resolver) ClearOverride ¶
ClearOverride removes any stored override for the named provider, so the next lookup falls back to the baked default.
func (*Resolver) EffectiveKey ¶
EffectiveKey returns the key that should actually be used for API calls to the named provider. Empty string means "not configured" — callers should return a 503 to the caller with a helpful message.
func (*Resolver) HasOverride ¶
HasOverride reports whether an override is currently stored for the named provider (separate from whether a baked default exists).
type Store ¶
type Store interface {
GetSetting(ctx context.Context, key string) (string, error)
SetSetting(ctx context.Context, arg db.SetSettingParams) error
DeleteSetting(ctx context.Context, key string) error
}
Store is the subset of the DB queries interface this package needs. Accepts *db.Queries and any handwritten implementation that matches.