Skip to content

Commit

Permalink
ionos: follow CNAME (#2281)
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez authored Sep 19, 2024
1 parent 0da0942 commit 69bd2e0
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions providers/dns/ionos/ionos.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}

Expand All @@ -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",
Expand All @@ -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",
}

Expand All @@ -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)
Expand Down

0 comments on commit 69bd2e0

Please sign in to comment.