Documentation
¶
Index ¶
- Constants
- func DefaultTMDBKey() string
- func DefaultTraktClientID() string
- func EnsureAPIKey(cfg *Config) (generated bool, err error)
- func WriteConfigKey(configFile, key, value string) (writePath string, err error)
- type AuthConfig
- type Config
- type DatabaseConfig
- type LogConfig
- type PulseConfig
- type Secret
- type ServerConfig
- type TMDBConfig
- type TraktConfig
Constants ¶
const ( DefaultHost = "0.0.0.0" DefaultPort = 8383 DefaultDBDriver = "postgres" DefaultLogLevel = "info" DefaultLogFormat = "json" )
Variables ¶
This section is empty.
Functions ¶
func DefaultTMDBKey ¶
func DefaultTMDBKey() string
DefaultTMDBKey returns the baked-in TMDB API key (de-obfuscated) or an empty string if no key was provided at build time. This is the only way the key appears in plaintext — never log, never return via an API response.
func DefaultTraktClientID ¶
func DefaultTraktClientID() string
DefaultTraktClientID returns the baked-in Trakt client ID.
func EnsureAPIKey ¶
EnsureAPIKey generates a random API key if none is configured.
func WriteConfigKey ¶
WriteConfigKey writes a single dot-notation key (e.g. "auth.api_key") to the given YAML config file, creating the file and parent directories if needed.
Types ¶
type AuthConfig ¶
type AuthConfig struct {
APIKey Secret `mapstructure:"api_key"`
}
AuthConfig holds the Pilot API key used to authenticate requests.
type Config ¶
type Config struct {
Server ServerConfig `mapstructure:"server"`
Database DatabaseConfig `mapstructure:"database"`
Log LogConfig `mapstructure:"log"`
Auth AuthConfig `mapstructure:"auth"`
TMDB TMDBConfig `mapstructure:"tmdb"`
Trakt TraktConfig `mapstructure:"trakt"`
Pulse PulseConfig `mapstructure:"pulse"`
// ConfigFile is the path of the config file that was loaded, if any.
// Empty when running on defaults/env vars only.
ConfigFile string `mapstructure:"-"`
// TMDBKeyIsDefault is true when the TMDB key came from the build-time
// baked-in default rather than user config or env. Surfaced via
// /api/v1/system/config so the UI can prompt for a custom key.
TMDBKeyIsDefault bool `mapstructure:"-"`
}
Config holds all application configuration. Values are loaded from config.yaml and can be overridden by PILOT_* environment variables (e.g. PILOT_SERVER_PORT=8383).
func Load ¶
Load reads configuration from a YAML file and environment variables. If cfgFile is empty, the following paths are searched in order:
/config/config.yaml (Docker volume mount) $HOME/.config/pilot/config.yaml /etc/pilot/config.yaml ./config.yaml
Missing config file is not an error — defaults and environment variables are always applied.
type DatabaseConfig ¶
type DatabaseConfig struct {
// Driver is "sqlite" (default) or "postgres".
Driver string `mapstructure:"driver"`
// Path is the SQLite database file path. Ignored for Postgres.
Path string `mapstructure:"path"`
// DSN is the Postgres connection string. Ignored for SQLite.
DSN Secret `mapstructure:"dsn"`
// PasswordFile is a path to a file containing the Postgres password,
// typically a Docker secret mounted at /run/secrets/*. When non-empty,
// its contents replace the password component of DSN at load time.
PasswordFile string `mapstructure:"password_file"`
}
DatabaseConfig selects and configures the database driver.
type LogConfig ¶
type LogConfig struct {
// Level is one of: debug, info, warn, error. Default: info.
Level string `mapstructure:"level"`
// Format is one of: json, text. Default: json.
Format string `mapstructure:"format"`
}
LogConfig controls log output format and verbosity.
type PulseConfig ¶
type PulseConfig struct {
URL string `mapstructure:"url"`
APIKey Secret `mapstructure:"api_key"`
// APIKeyFile points at a file (typically /run/secrets/*) containing
// Pulse's API key. When non-empty, its contents replace APIKey at
// load time.
APIKeyFile string `mapstructure:"api_key_file"`
}
PulseConfig holds optional Beacon Pulse integration settings.
type Secret ¶
type Secret string
Secret is a string type that never reveals its contents when logged, printed, or serialized. Use it for API keys, passwords, and tokens.
Call .Value() when you actually need the underlying string (e.g. to make an authenticated HTTP request).
func (Secret) LogValue ¶
LogValue implements slog.LogValuer. Always returns "***". Prevents exposure in structured log output.
func (Secret) MarshalJSON ¶
MarshalJSON always serializes as the string "***". Prevents accidental exposure in JSON API responses.
func (Secret) MarshalText ¶
MarshalText always encodes as "***". Covers YAML, TOML, and other text-based serializers.
type ServerConfig ¶
ServerConfig controls the HTTP server.
type TMDBConfig ¶
type TMDBConfig struct {
APIKey Secret `mapstructure:"api_key"`
}
TMDBConfig holds the TMDB (themoviedb.org) API credentials. Pilot uses TMDB's TV API for series metadata; despite the name, TMDB covers both movies and TV. A single TMDB key works for both Pilot and Prism.
type TraktConfig ¶
type TraktConfig struct {
ClientID Secret `mapstructure:"client_id"`
}
TraktConfig holds the Trakt API key used for import list plugins.