Files
realDynDNS/pkg/config/config.go
Timo Behrendt 7bb1e9ca08
All checks were successful
CD / test (push) Successful in 48s
CD / Build and push (push) Successful in 3m48s
feat: notification provider (#8)
Co-authored-by: Timo Behrendt <t.behrendt@t00n.de>
Co-committed-by: Timo Behrendt <t.behrendt@t00n.de>
2024-08-11 11:52:51 +02:00

50 lines
1.1 KiB
Go

package config
import (
"os"
"gopkg.in/yaml.v3"
)
type DomainConfig struct {
TLD string `yaml:"tld"`
Subdomains []string `yaml:"subdomains"`
}
type Config struct {
ExternalIPProvider ExternalIpProviderConfig `yaml:"ip_provider"`
DNSProvider DNSProviderConfig `yaml:"dns_provider"`
NotificationProvider NotificationProviderConfig `yaml:"notification_provider,omitempty"`
Domains []DomainConfig `yaml:"domains"`
CheckInterval string `yaml:"check_interval"`
}
type ExternalIpProviderConfig struct {
Type string `yaml:"type"`
ProviderConfig yaml.Node `yaml:"config"`
}
type DNSProviderConfig struct {
Type string `yaml:"type"`
ProviderConfig yaml.Node `yaml:"config"`
}
type NotificationProviderConfig struct {
Type string `yaml:"type"`
ProviderConfig yaml.Node `yaml:"config"`
}
func (c *Config) Load(filePath string) error {
err := yaml.Unmarshal([]byte(filePath), c)
if err != nil {
inputConfig, err := os.ReadFile(filePath)
if err != nil {
return err
}
return yaml.Unmarshal(inputConfig, c)
}
return err
}