Documentation
¶
Overview ¶
Package config provides application configuration loading and validation.
Index ¶
- type AppleTV
- type Config
- type Connection
- type HAConfig
- type PlexServer
- type RuntimeConfig
- func (c *RuntimeConfig) GetAppleTVByEntity(entity string) *AppleTV
- func (c *RuntimeConfig) GetDefaultAppleTV() *AppleTV
- func (c *RuntimeConfig) GetPlexServerByID(id string) *PlexServer
- func (c *RuntimeConfig) IsEmpty() bool
- func (c *RuntimeConfig) Save(path string) error
- func (c *RuntimeConfig) Validate() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AppleTV ¶
type AppleTV struct {
Entity string `yaml:"entity"`
Name string `yaml:"name"`
Default bool `yaml:"default"`
}
AppleTV represents an Apple TV media player
type Config ¶
type Config struct {
Port string
DataDir string // Directory for all generated files (database, secrets)
LogLevel string
SessionSecret string
CSRFKey []byte // 32-byte key for CSRF protection
EncryptionKey []byte // 32-byte key for AES-256-GCM encryption
DevMode bool
RequireTLS bool
}
Config holds application-level configuration from environment variables. User data (Plex servers, Home Assistant, Apple TVs) is stored in config.yml and loaded via LoadRuntimeConfig().
func Load ¶
Load reads configuration from environment variables and validates required fields. It attempts to load from a .env file if present, then reads from the environment. Generates and persists a random SESSION_SECRET if not set.
func (*Config) ConfigPath ¶
ConfigPath returns the full path to the runtime configuration file
func (*Config) DatabasePath ¶
DatabasePath returns the full path to the database file
type Connection ¶
Connection represents a Plex server connection URL
type HAConfig ¶
type HAConfig struct {
URL string `yaml:"url"`
}
HAConfig represents Home Assistant configuration
type PlexServer ¶
type PlexServer struct {
ID string `yaml:"id"`
Name string `yaml:"name"`
Owner string `yaml:"owner"`
Connections []Connection `yaml:"connections"`
}
PlexServer represents a Plex Media Server configuration
type RuntimeConfig ¶
type RuntimeConfig struct {
Version int `yaml:"version"`
PlexServers []PlexServer `yaml:"plex_servers"`
HomeAssistant HAConfig `yaml:"home_assistant"`
AppleTVs []AppleTV `yaml:"apple_tvs"`
}
RuntimeConfig represents the user-configurable runtime settings
func LoadRuntimeConfig ¶
func LoadRuntimeConfig(path string) (*RuntimeConfig, error)
LoadRuntimeConfig loads configuration from a YAML file
func (*RuntimeConfig) GetAppleTVByEntity ¶
func (c *RuntimeConfig) GetAppleTVByEntity(entity string) *AppleTV
GetAppleTVByEntity finds an Apple TV by its entity ID
func (*RuntimeConfig) GetDefaultAppleTV ¶
func (c *RuntimeConfig) GetDefaultAppleTV() *AppleTV
GetDefaultAppleTV returns the default Apple TV, or the first one if none is marked default
func (*RuntimeConfig) GetPlexServerByID ¶
func (c *RuntimeConfig) GetPlexServerByID(id string) *PlexServer
GetPlexServerByID finds a Plex server by its ID
func (*RuntimeConfig) IsEmpty ¶
func (c *RuntimeConfig) IsEmpty() bool
IsEmpty returns true if the configuration has no servers or HA configured
func (*RuntimeConfig) Save ¶
func (c *RuntimeConfig) Save(path string) error
Save writes the configuration to a YAML file
func (*RuntimeConfig) Validate ¶
func (c *RuntimeConfig) Validate() error
Validate checks if the configuration is valid