feat: notification provider (#8)
All checks were successful
CD / test (push) Successful in 48s
CD / Build and push (push) Successful in 3m48s

Co-authored-by: Timo Behrendt <t.behrendt@t00n.de>
Co-committed-by: Timo Behrendt <t.behrendt@t00n.de>
This commit was merged in pull request #8.
This commit is contained in:
2024-08-11 11:52:51 +02:00
committed by t.behrendt
parent b8bdcaa35e
commit 7bb1e9ca08
11 changed files with 304 additions and 31 deletions

View File

@@ -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 {

View File

@@ -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)