diff --git a/providers/packetframe/packetframeProvider.go b/providers/packetframe/packetframeProvider.go index 907c042ed..85384198b 100644 --- a/providers/packetframe/packetframeProvider.go +++ b/providers/packetframe/packetframeProvider.go @@ -228,7 +228,7 @@ func toRc(dc *models.DomainConfig, r *domainRecord) *models.RecordConfig { switch rtype := r.Type; rtype { // #rtype_variations case "TXT": - rc.SetTargetTXTString(r.Value) + rc.SetTargetTXT(r.Value) case "SRV": spl := strings.Split(r.Value, " ") prio, _ := strconv.ParseUint(spl[0], 10, 16) diff --git a/providers/powerdns/dns.go b/providers/powerdns/dns.go index 7d09cfc9f..24f834a0f 100644 --- a/providers/powerdns/dns.go +++ b/providers/powerdns/dns.go @@ -62,73 +62,71 @@ func (dsp *powerdnsProvider) GetDomainCorrections(dc *models.DomainConfig) ([]*m } models.PostProcessRecords(curRecords) - var corrections []*models.Correction - if !diff2.EnableDiff2 || true { // Remove "|| true" when diff2 version arrives + // create record diff by group + var keysToUpdate map[models.RecordKey][]string + if !diff2.EnableDiff2 { + keysToUpdate, err = (diff.New(dc)).ChangedGroups(curRecords) + } else { + keysToUpdate, err = (diff.NewCompat(dc)).ChangedGroups(curRecords) + } + if err != nil { + return nil, err + } + desiredRecords := dc.Records.GroupedByKey() - // create record diff by group - keysToUpdate, err := (diff.New(dc)).ChangedGroups(curRecords) - if err != nil { - return nil, err - } - desiredRecords := dc.Records.GroupedByKey() + var cuCorrections []*models.Correction + var dCorrections []*models.Correction - var cuCorrections []*models.Correction - var dCorrections []*models.Correction + // add create/update and delete corrections separately + for label, msgs := range keysToUpdate { + labelName := label.NameFQDN + "." + labelType := label.Type + msgJoined := strings.Join(msgs, "\n ") - // add create/update and delete corrections separately - for label, msgs := range keysToUpdate { - labelName := label.NameFQDN + "." - labelType := label.Type - msgJoined := strings.Join(msgs, "\n ") - - if _, ok := desiredRecords[label]; !ok { - // no record found so delete it - dCorrections = append(dCorrections, &models.Correction{ - Msg: msgJoined, - F: func() error { - return dsp.client.Zones().RemoveRecordSetFromZone(context.Background(), dsp.ServerName, dc.Name, labelName, labelType) - }, - }) - } else { - // record found so create or update it - ttl := desiredRecords[label][0].TTL - var records []zones.Record - for _, recordContent := range desiredRecords[label] { - records = append(records, zones.Record{ - Content: recordContent.GetTargetCombined(), - }) - } - cuCorrections = append(cuCorrections, &models.Correction{ - Msg: msgJoined, - F: func() error { - return dsp.client.Zones().AddRecordSetToZone(context.Background(), dsp.ServerName, dc.Name, zones.ResourceRecordSet{ - Name: labelName, - Type: labelType, - TTL: int(ttl), - Records: records, - ChangeType: zones.ChangeTypeReplace, - }) - }, + if _, ok := desiredRecords[label]; !ok { + // no record found so delete it + dCorrections = append(dCorrections, &models.Correction{ + Msg: msgJoined, + F: func() error { + return dsp.client.Zones().RemoveRecordSetFromZone(context.Background(), dsp.ServerName, dc.Name, labelName, labelType) + }, + }) + } else { + // record found so create or update it + ttl := desiredRecords[label][0].TTL + var records []zones.Record + for _, recordContent := range desiredRecords[label] { + records = append(records, zones.Record{ + Content: recordContent.GetTargetCombined(), }) } + cuCorrections = append(cuCorrections, &models.Correction{ + Msg: msgJoined, + F: func() error { + return dsp.client.Zones().AddRecordSetToZone(context.Background(), dsp.ServerName, dc.Name, zones.ResourceRecordSet{ + Name: labelName, + Type: labelType, + TTL: int(ttl), + Records: records, + ChangeType: zones.ChangeTypeReplace, + }) + }, + }) } - - // append corrections in the right order - // delete corrections must be run first to avoid correlations with existing RR - corrections = append(corrections, dCorrections...) - corrections = append(corrections, cuCorrections...) - - // DNSSec corrections - dnssecCorrections, err := dsp.getDNSSECCorrections(dc) - if err != nil { - return nil, err - } - corrections = append(corrections, dnssecCorrections...) - - return corrections, nil } - // Insert Future diff2 version here. + // append corrections in the right order + // delete corrections must be run first to avoid correlations with existing RR + var corrections []*models.Correction + corrections = append(corrections, dCorrections...) + corrections = append(corrections, cuCorrections...) + + // DNSSec corrections + dnssecCorrections, err := dsp.getDNSSECCorrections(dc) + if err != nil { + return nil, err + } + corrections = append(corrections, dnssecCorrections...) return corrections, nil }