feat: add notification provider
This commit is contained in:
@@ -12,10 +12,11 @@ type DomainConfig struct {
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
ExternalIPProvider ExternalIpProviderConfig `yaml:"ip_provider"`
|
||||
DNSProvider DNSProviderConfig `yaml:"dns_provider"`
|
||||
Domains []DomainConfig `yaml:"domains"`
|
||||
CheckInterval string `yaml:"check_interval"`
|
||||
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 {
|
||||
@@ -28,6 +29,11 @@ type DNSProviderConfig struct {
|
||||
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 {
|
||||
|
||||
@@ -49,6 +49,10 @@ dns_provider:
|
||||
config:
|
||||
api_key: exampleAPIKey
|
||||
base_url: https://example.com
|
||||
notification_provider:
|
||||
type: gotify
|
||||
config:
|
||||
url: https://example.com
|
||||
domains:
|
||||
- tld: example.com
|
||||
subdomains:
|
||||
@@ -56,7 +60,7 @@ domains:
|
||||
- www
|
||||
check_interval: 0 0 0/6 * * * *`)
|
||||
|
||||
want := c.DNSProvider.Type == "ionos" && c.ExternalIPProvider.Type == "plain"
|
||||
want := c.DNSProvider.Type == "ionos" && c.ExternalIPProvider.Type == "plain" && c.NotificationProvider.Type == "gotify"
|
||||
|
||||
if !want || err != nil {
|
||||
t.Fatalf("DnsProviderName couldn't be properly loaded or unmarshaled, Load() = %v, want %v", err, want)
|
||||
|
||||
Reference in New Issue
Block a user