ionos: follow CNAME (#2281)

This commit is contained in:
Ludovic Fernandez 2024-09-19 15:29:20 +02:00 committed by GitHub
parent 0da0942081
commit 69bd2e0373
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -113,14 +113,15 @@ func (d *DNSProvider) Present(domain, _, keyAuth string) error {
return fmt.Errorf("ionos: failed to get zones: %w", err) return fmt.Errorf("ionos: failed to get zones: %w", err)
} }
// TODO(ldez) replace domain by FQDN to follow CNAME. name := dns01.UnFqdn(info.EffectiveFQDN)
zone := findZone(zones, domain)
zone := findZone(zones, name)
if zone == nil { if zone == nil {
return errors.New("ionos: no matching zone found for domain") return errors.New("ionos: no matching zone found for domain")
} }
filter := &internal.RecordsFilter{ filter := &internal.RecordsFilter{
Suffix: dns01.UnFqdn(info.EffectiveFQDN), Suffix: name,
RecordType: "TXT", RecordType: "TXT",
} }
@ -130,7 +131,7 @@ func (d *DNSProvider) Present(domain, _, keyAuth string) error {
} }
records = append(records, internal.Record{ records = append(records, internal.Record{
Name: dns01.UnFqdn(info.EffectiveFQDN), Name: name,
Content: info.Value, Content: info.Value,
TTL: d.config.TTL, TTL: d.config.TTL,
Type: "TXT", Type: "TXT",
@ -155,14 +156,15 @@ func (d *DNSProvider) CleanUp(domain, _, keyAuth string) error {
return fmt.Errorf("ionos: failed to get zones: %w", err) return fmt.Errorf("ionos: failed to get zones: %w", err)
} }
// TODO(ldez) replace domain by FQDN to follow CNAME. name := dns01.UnFqdn(info.EffectiveFQDN)
zone := findZone(zones, domain)
zone := findZone(zones, name)
if zone == nil { if zone == nil {
return errors.New("ionos: no matching zone found for domain") return errors.New("ionos: no matching zone found for domain")
} }
filter := &internal.RecordsFilter{ filter := &internal.RecordsFilter{
Suffix: dns01.UnFqdn(info.EffectiveFQDN), Suffix: name,
RecordType: "TXT", RecordType: "TXT",
} }
@ -172,7 +174,7 @@ func (d *DNSProvider) CleanUp(domain, _, keyAuth string) error {
} }
for _, record := range records { for _, record := range records {
if record.Name == dns01.UnFqdn(info.EffectiveFQDN) && record.Content == strconv.Quote(info.Value) { if record.Name == name && record.Content == strconv.Quote(info.Value) {
err = d.client.RemoveRecord(ctx, zone.ID, record.ID) err = d.client.RemoveRecord(ctx, zone.ID, record.ID)
if err != nil { if err != nil {
return fmt.Errorf("ionos: failed to remove record (zone=%s, record=%s): %w", zone.ID, record.ID, err) return fmt.Errorf("ionos: failed to remove record (zone=%s, record=%s): %w", zone.ID, record.ID, err)