From 69bd2e03732b239d330836654a2c8114024ec7fd Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Thu, 19 Sep 2024 15:29:20 +0200 Subject: [PATCH] ionos: follow CNAME (#2281) --- providers/dns/ionos/ionos.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/providers/dns/ionos/ionos.go b/providers/dns/ionos/ionos.go index 6a778f2b2c..fc322c8943 100644 --- a/providers/dns/ionos/ionos.go +++ b/providers/dns/ionos/ionos.go @@ -113,14 +113,15 @@ func (d *DNSProvider) Present(domain, _, keyAuth string) error { return fmt.Errorf("ionos: failed to get zones: %w", err) } - // TODO(ldez) replace domain by FQDN to follow CNAME. - zone := findZone(zones, domain) + name := dns01.UnFqdn(info.EffectiveFQDN) + + zone := findZone(zones, name) if zone == nil { return errors.New("ionos: no matching zone found for domain") } filter := &internal.RecordsFilter{ - Suffix: dns01.UnFqdn(info.EffectiveFQDN), + Suffix: name, RecordType: "TXT", } @@ -130,7 +131,7 @@ func (d *DNSProvider) Present(domain, _, keyAuth string) error { } records = append(records, internal.Record{ - Name: dns01.UnFqdn(info.EffectiveFQDN), + Name: name, Content: info.Value, TTL: d.config.TTL, Type: "TXT", @@ -155,14 +156,15 @@ func (d *DNSProvider) CleanUp(domain, _, keyAuth string) error { return fmt.Errorf("ionos: failed to get zones: %w", err) } - // TODO(ldez) replace domain by FQDN to follow CNAME. - zone := findZone(zones, domain) + name := dns01.UnFqdn(info.EffectiveFQDN) + + zone := findZone(zones, name) if zone == nil { return errors.New("ionos: no matching zone found for domain") } filter := &internal.RecordsFilter{ - Suffix: dns01.UnFqdn(info.EffectiveFQDN), + Suffix: name, RecordType: "TXT", } @@ -172,7 +174,7 @@ func (d *DNSProvider) CleanUp(domain, _, keyAuth string) error { } 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) if err != nil { return fmt.Errorf("ionos: failed to remove record (zone=%s, record=%s): %w", zone.ID, record.ID, err)