Switch config format from YAML to TOML

Replaces gopkg.in/yaml.v3 with github.com/BurntSushi/toml. Updates
struct tags, default config path, Dockerfile CMD, README, and ships
config.example.toml in place of the YAML example. ${ENV_VAR}
expansion still runs on the raw file before parsing, so the behavior
is unchanged.
This commit is contained in:
prosolis
2026-05-24 21:05:41 -07:00
parent 035089c159
commit 8f38d3d9f4
8 changed files with 72 additions and 71 deletions

View File

@@ -6,42 +6,42 @@ import (
"os"
"regexp"
"gopkg.in/yaml.v3"
"github.com/BurntSushi/toml"
)
var envBracketRe = regexp.MustCompile(`\$\{([^}]+)\}`)
type Config struct {
Matrix MatrixConfig `yaml:"matrix"`
Services ServicesConfig `yaml:"services"`
Matrix MatrixConfig `toml:"matrix"`
Services ServicesConfig `toml:"services"`
}
type MatrixConfig struct {
Homeserver string `yaml:"homeserver"`
UserID string `yaml:"user_id"`
Password string `yaml:"password"`
PickleKey string `yaml:"pickle_key"`
DisplayName string `yaml:"display_name"`
DataDir string `yaml:"data_dir"`
CommandPrefix string `yaml:"command_prefix"`
Homeserver string `toml:"homeserver"`
UserID string `toml:"user_id"`
Password string `toml:"password"`
PickleKey string `toml:"pickle_key"`
DisplayName string `toml:"display_name"`
DataDir string `toml:"data_dir"`
CommandPrefix string `toml:"command_prefix"`
// AllowedRooms is the set of room IDs the bot listens for commands in.
// Messages in any other room are ignored.
AllowedRooms []string `yaml:"allowed_rooms"`
AllowedRooms []string `toml:"allowed_rooms"`
}
type ServicesConfig struct {
Radarr *ArrConfig `yaml:"radarr"`
Sonarr *ArrConfig `yaml:"sonarr"`
Lidarr *ArrConfig `yaml:"lidarr"`
Radarr *ArrConfig `toml:"radarr"`
Sonarr *ArrConfig `toml:"sonarr"`
Lidarr *ArrConfig `toml:"lidarr"`
}
type ArrConfig struct {
URL string `yaml:"url"`
APIKey string `yaml:"api_key"`
QualityProfileID int `yaml:"quality_profile_id"`
RootFolder string `yaml:"root_folder"`
URL string `toml:"url"`
APIKey string `toml:"api_key"`
QualityProfileID int `toml:"quality_profile_id"`
RootFolder string `toml:"root_folder"`
// MetadataProfileID is required by Lidarr; ignored by Radarr/Sonarr.
MetadataProfileID int `yaml:"metadata_profile_id"`
MetadataProfileID int `toml:"metadata_profile_id"`
}
func Load(path string) (*Config, error) {
@@ -60,7 +60,7 @@ func Load(path string) (*Config, error) {
})
var cfg Config
if err := yaml.Unmarshal([]byte(expanded), &cfg); err != nil {
if _, err := toml.Decode(expanded, &cfg); err != nil {
return nil, fmt.Errorf("parse config: %w", err)
}