Skip to content

Commit

Permalink
fix(gandi): conversion to @ for apex domains is not robust
Browse files Browse the repository at this point in the history
  • Loading branch information
gfaugere committed Aug 24, 2023
1 parent 5a6e12f commit c5b488d
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions provider/gandi/gandi.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,28 @@ func (p *GandiProvider) submitChanges(ctx context.Context, changes []*GandiChang

for _, changes := range zoneChanges {
for _, change := range changes {
// Prepare record name
recordName := strings.TrimSuffix(change.Record.RrsetName, "."+change.ZoneName)
if recordName == change.ZoneName {
recordName = "@"
}
if change.Record.RrsetType == endpoint.RecordTypeCNAME && !strings.HasSuffix(change.Record.RrsetValues[0], ".") {
change.Record.RrsetValues[0] += "."
}
change.Record.RrsetName = recordName

// Prepare record name
if change.Record.RrsetName == change.ZoneName {
log.WithFields(log.Fields{
"record": change.Record.RrsetName,
"type": change.Record.RrsetType,
"value": change.Record.RrsetValues[0],
"ttl": change.Record.RrsetTTL,
"action": change.Action,
"zone": change.ZoneName,
}).Debugf("Converting record name: %s to apex domain (@)", change.Record.RrsetName)

change.Record.RrsetName = "@"
} else {
change.Record.RrsetName = strings.TrimSuffix(
change.Record.RrsetName,
"."+change.ZoneName,
)
}

log.WithFields(log.Fields{
"record": change.Record.RrsetName,
Expand Down

0 comments on commit c5b488d

Please sign in to comment.