Documentation
¶
Overview ¶
Package config provides configuration loading for Schedularr. Configuration structure and defaults are defined by CUE schemas in cmd/schema/. This package re-exports cueconfig types and provides loading helpers.
Package config provides configuration loading for Schedularr.
Index ¶
- Constants
- func APIInsecureNoAuth(cfg *Config) bool
- func APIListen(cfg *Config) string
- func APIToken(cfg *Config) string
- func CronInterval(cfg *Config) time.Duration
- func DatabasePath(cfg *Config) string
- func EnsureDirectories(p *Paths) error
- func FindConfigFile(flagValue string) string
- func LogFormat(cfg *Config) string
- func LogLevel(cfg *Config) string
- func LogTimezone(cfg *Config) string
- func LogsDir(cfg *Config) string
- func MaintenanceApplyRunRetention(cfg *Config) time.Duration
- func MaintenanceCleanupEnabled(cfg *Config) bool
- func MaintenanceHistoryRetention(cfg *Config) time.Duration
- func MaintenanceSnapshotRetention(cfg *Config) time.Duration
- func SchedulerFilePath(cfg *Config) string
- func TunarrConfig(cfg *Config) tunarr.Config
- type Config
- type Paths
Constants ¶
const ( // EnvConfigPath is the environment variable for config file path. EnvConfigPath = "SCHEDULARR_CONFIG" // EnvAPIToken is the *name* of the environment variable carrying the // `serve` command's bearer token -- not a credential itself, just the // key config.APIToken reads via os.Getenv. It always wins over the // api.token config key -- see APIToken. // #nosec G101 -- this is an env var name, not a hardcoded credential EnvAPIToken = "SCHEDULARR_API_TOKEN" // DefaultConfigDir is the default config directory name. DefaultConfigDir = ".schedularr" // DefaultDataDir is the default data directory name. DefaultDataDir = "schedularr" // DefaultConfigFile is the default config file name. DefaultConfigFile = "config.yaml" // DefaultLogsDir is the default logs directory name. DefaultLogsDir = "logs" )
Variables ¶
This section is empty.
Functions ¶
func APIInsecureNoAuth ¶
APIInsecureNoAuth returns whether the `serve` command's API server should skip bearer-auth on /api/v1/* entirely (api.Config.InsecureNoAuth). Local development only.
func APIListen ¶
APIListen returns the configured address for the `serve` command's HTTP API server to listen on (host:port, or :port for all interfaces).
func APIToken ¶
APIToken returns the bearer token the `serve` command's API server requires on /api/v1/* requests. The SCHEDULARR_API_TOKEN environment variable always wins over the api.token config key: operators rotate a deployed token via the environment (a systemd unit's Environment=, a Docker secret, ...) independently of whatever's checked into the config file, and an env-var override is easier to keep out of version control than a config value.
func CronInterval ¶
CronInterval returns the configured interval between the `serve` command's cron-loop schedule regenerate-and-apply cycles, CUE-defaulting to 6h when the config file doesn't set cron_interval. This is a top-level key, not under api.*, because it governs the scheduler's cron behavior, not the HTTP server -- `serve --interval`/`-i` overrides this value when passed explicitly (flag > config > 6h default).
func DatabasePath ¶
DatabasePath returns the configured database path.
func EnsureDirectories ¶
EnsureDirectories creates all required directories if they don't exist. Uses os.MkdirAll with 0750 permissions (owner: rwx, group: rx, others: none).
func FindConfigFile ¶
FindConfigFile searches for a config file in standard locations. Returns the path to the first existing config file, or empty string if none found.
func LogTimezone ¶
LogTimezone returns the configured timezone.
func LogsDir ¶
LogsDir returns the configured logs directory from the app config, or the default path if not configured.
func MaintenanceApplyRunRetention ¶ added in v0.5.7
MaintenanceApplyRunRetention returns how long apply-run records and their warnings are kept (default 90 days).
func MaintenanceCleanupEnabled ¶
MaintenanceCleanupEnabled returns whether cleanup is enabled.
func MaintenanceHistoryRetention ¶
MaintenanceHistoryRetention returns the history retention duration.
func MaintenanceSnapshotRetention ¶ added in v0.5.7
MaintenanceSnapshotRetention returns how long series occurrence snapshots are kept. Split from history_retention in v0.5.7 so the two tables prune on their own clocks.
func SchedulerFilePath ¶
SchedulerFilePath returns the configured path of the scheduler.yaml import file (see blockio.Bootstrap). scheduler.yaml is import-only: it seeds the block store on first run and is otherwise ignored, so this is only ever consulted for that one-time bootstrap.
func TunarrConfig ¶
TunarrConfig extracts Tunarr client configuration from the loaded config.
Types ¶
type Config ¶
Config is an alias for cueconfig.Config All config access should use the accessor methods (GetString, GetInt, etc.)
type Paths ¶
Paths holds resolved paths for Schedularr directories and files.
func DefaultPaths ¶
DefaultPaths returns OS-agnostic default paths based on user home directory. Config: $HOME/.schedularr/config.yaml Logs: $HOME/schedularr/logs/
func ResolvePaths ¶
ResolvePaths determines paths using the priority: flag > env > default. The flagValue parameter is the --config flag value (empty if not set).