Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewValidator ¶
NewValidator returns a validator configured with custom validators for MediaType values (mediatype) and Hatchet 6-field cron expressions (hatchetcron).
Types ¶
type CompiledRegexp ¶
CompiledRegexp is a Go regular expression that is compiled at YAML parse time. An invalid expression causes YAML unmarshaling (and therefore config loading) to fail with a descriptive error, so no separate validation step is required.
func (CompiledRegexp) JSONSchema ¶
func (CompiledRegexp) JSONSchema() *jsonschema.Schema
JSONSchema returns a JSON Schema for CompiledRegexp. The type serialises as a scalar string (the regex pattern) at YAML parse time; reflecting the Go struct would produce an empty object schema, so this method overrides that to describe the on-disk shape accurately.
func (*CompiledRegexp) UnmarshalYAML ¶
func (c *CompiledRegexp) UnmarshalYAML(value *yaml.Node) error
UnmarshalYAML compiles the scalar YAML string as a Go regular expression. It returns an error if the node is not a scalar string, if the string is empty, or if the expression is invalid.
type Config ¶
type Config struct {
// CronSchedule controls how often the watcher scans directories (default: every 5 seconds).
// Uses Hatchet's 6-field cron format with a leading seconds field, e.g. "*/5 * * * * *".
CronSchedule CronExpression `yaml:"cronSchedule,omitempty" validate:"omitempty,hatchetcron"`
// Watches lists the directories to monitor and their associated media types.
Watches []WatchEntry `yaml:"watches,omitempty" validate:"dive"`
}
Config is the top-level watcher configuration loaded from the YAML config file.
func (*Config) SetDefaults ¶
func (cfg *Config) SetDefaults()
SetDefaults implements defaults.Setter to initialize Config fields from package constants, avoiding duplicate literal values in struct tags.
type CronExpression ¶
type CronExpression string
CronExpression is a Hatchet 6-field cron expression (seconds-leading, e.g. "*/5 * * * * *"). It implements JSONSchema to embed the pattern constraint in the generated schema, keeping the regex defined in validate.go as the single source of truth for both schema and runtime checks.
const DefaultCronSchedule CronExpression = "*/5 * * * * *"
DefaultCronSchedule is the Hatchet cron expression used when none is specified in the config.
func (CronExpression) JSONSchema ¶
func (CronExpression) JSONSchema() *jsonschema.Schema
JSONSchema returns a JSON Schema for CronExpression using the canonical Hatchet cron regex.
type WatchEntry ¶
type WatchEntry struct {
// Name is a human-readable label for this watch entry, used in logs and metrics.
Name string `yaml:"name" jsonschema:"minLength=1" validate:"min=1"`
// WatchedPath is the filesystem path to the directory to watch. Relative paths are resolved
// against the watcher's working directory.
WatchedPath string `yaml:"watchedPath" jsonschema:"minLength=1" validate:"min=1"`
// MediaType indicates whether this directory contains movies or TV show episodes.
MediaType medialib.MediaType `yaml:"mediaType" validate:"mediatype"`
// IgnorePatterns is an optional list of Go regular expressions matched against the absolute
// path of each file and directory encountered during a scan. A matching file is silently
// skipped; a matching directory causes its entire subtree to be pruned. Patterns are
// compiled when the configuration is loaded; an invalid expression causes configuration loading to fail.
IgnorePatterns []CompiledRegexp `yaml:"ignorePatterns,omitempty" validate:"omitempty"`
// PreserveSource controls whether the source file is deleted after successful processing.
// When true, the source file is kept; when false or omitted, the source file is deleted
// (default behaviour).
PreserveSource bool `yaml:"preserveSource,omitempty"`
// RetainEmptyDirectories controls whether empty parent directories are removed after the
// source file is deleted. When false or omitted (the default), parent directories that
// become empty as a result of source-file deletion are pruned bottom-up, stopping at the
// watch root. When true, no directory removal is performed.
RetainEmptyDirectories bool `yaml:"retainEmptyDirectories,omitempty"`
// Output describes where processed files are written and how the output path is translated
// for the arr service.
Output WatchEntryOutput `yaml:"output"`
}
WatchEntry describes a watched location, mapping a filesystem path to a media type for dispatch and carrying a human-readable name for identification.
type WatchEntryOutput ¶ added in v0.0.3
type WatchEntryOutput struct {
// Path is the filesystem path to the directory where processed files are written.
Path string `yaml:"path" jsonschema:"minLength=1" validate:"min=1"`
// RemotePath is the path by which the output directory is known to the arr service (Radarr/Sonarr).
// Set this when the worker and the arr service mount the output volume at different paths.
// When empty, no path translation is applied.
RemotePath string `yaml:"remotePath,omitempty"`
}
WatchEntryOutput describes the output destination for a watch entry.