config

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	DefaultHost          = "0.0.0.0"
	DefaultPort          = 8282
	DefaultLogLevel      = "info"
	DefaultLogFormat     = "json"
	DefaultAIMatchModel  = "claude-sonnet-4-6"
	DefaultAIScoreModel  = "claude-haiku-4-5-20251001"
	DefaultAIFilterModel = "claude-haiku-4-5-20251001"
)

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. The generated key is returned and must be shown to the user — it is only ever logged once.

func WriteConfigKey

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

WriteConfigKey writes a single dot-notation key (e.g. "tmdb.api_key") to the given YAML config file, creating the file and parent directories if needed. If configFile is empty, the default path (~/.config/prism/config.yaml, or /config/config.yaml in Docker) is used.

Existing keys in the file are preserved; only the target key is updated. Returns the actual file path that was written.

Types

type AIConfig

type AIConfig struct {
	APIKey      Secret `mapstructure:"api_key"`
	MatchModel  string `mapstructure:"match_model"`
	ScoreModel  string `mapstructure:"score_model"`
	FilterModel string `mapstructure:"filter_model"`
}

AIConfig holds Claude API credentials and model selection.

type AuthConfig

type AuthConfig struct {
	APIKey Secret `mapstructure:"api_key"`
}

AuthConfig holds the Prism API key used to authenticate requests.

type Config

type Config struct {
	Server    ServerConfig    `mapstructure:"server"`
	Database  DatabaseConfig  `mapstructure:"database"`
	Log       LogConfig       `mapstructure:"log"`
	TMDB      TMDBConfig      `mapstructure:"tmdb"`
	Trakt     TraktConfig     `mapstructure:"trakt"`
	AI        AIConfig        `mapstructure:"ai"`
	Auth      AuthConfig      `mapstructure:"auth"`
	MediaInfo MediaInfoConfig `mapstructure:"mediainfo"`
	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
	// default rather than user configuration.
	TMDBKeyIsDefault bool `mapstructure:"-"`
}

Config holds all application configuration. Values are loaded from config.yaml and can be overridden by PRISM_* environment variables (e.g. PRISM_SERVER_PORT=8080).

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/prism/config.yaml
/etc/prism/config.yaml
./config.yaml

Missing config file is not an error — defaults and environment variables are always applied.

type DatabaseConfig

type DatabaseConfig struct {
	// Path is the SQLite database file location.
	Path string `mapstructure:"path"`
}

DatabaseConfig configures the SQLite database.

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 MediaInfoConfig

type MediaInfoConfig struct {
	// FFprobePath is the path to the ffprobe binary. Empty means search $PATH.
	FFprobePath string `mapstructure:"ffprobe_path"`
	// ScanTimeout is the per-file timeout for ffprobe. Default: "30s".
	ScanTimeout string `mapstructure:"scan_timeout"`
	// ScanOnImport enables automatic scanning after a successful import.
	ScanOnImport bool `mapstructure:"scan_on_import"`
}

MediaInfoConfig controls optional ffprobe-based media scanning.

type PulseConfig

type PulseConfig struct {
	// URL is the base URL of the Pulse instance (e.g. "http://pulse:9696").
	URL string `mapstructure:"url"`
	// APIKey is the Pulse API key.
	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 Pulse integration settings. When URL and APIKey are set, Prism will register itself with Pulse on startup and auto-discover ecosystem services.

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 Movie Database API credentials.

type TraktConfig

type TraktConfig struct {
	ClientID Secret `mapstructure:"client_id"`
}

TraktConfig holds the Trakt API credentials. The ClientID is the app-level API key (trakt-api-key header). Public endpoints only need this.

Jump to

Keyboard shortcuts

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