config

package
v0.0.0-...-d88c8eb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 6, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
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

func EnsureAPIKey(cfg *Config) (generated bool, err error)

EnsureAPIKey generates a random API key if none is configured.

func WriteConfigKey

func WriteConfigKey(configFile, key, value string) (writePath string, err error)

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

func Load(cfgFile string) (*Config, error)

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) GoString

func (s Secret) GoString() string

GoString implements fmt.GoStringer. Always returns "***".

func (Secret) IsEmpty

func (s Secret) IsEmpty() bool

IsEmpty reports whether the secret has no value.

func (Secret) LogValue

func (s Secret) LogValue() slog.Value

LogValue implements slog.LogValuer. Always returns "***". Prevents exposure in structured log output.

func (Secret) MarshalJSON

func (s Secret) MarshalJSON() ([]byte, error)

MarshalJSON always serializes as the string "***". Prevents accidental exposure in JSON API responses.

func (Secret) MarshalText

func (s Secret) MarshalText() ([]byte, error)

MarshalText always encodes as "***". Covers YAML, TOML, and other text-based serializers.

func (Secret) String

func (s Secret) String() string

String implements fmt.Stringer. Always returns "***".

func (Secret) Value

func (s Secret) Value() string

Value returns the underlying secret string. Only call this when the actual value is needed.

type ServerConfig

type ServerConfig struct {
	Host string `mapstructure:"host"`
	Port int    `mapstructure:"port"`
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL