mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
NETCUP: Adopt diff2 in compatibility mode (#1895)
This commit is contained in:
@@ -102,53 +102,52 @@ func (api *netcupProvider) GetDomainCorrections(dc *models.DomainConfig) ([]*mod
|
||||
// txtutil.SplitSingleLongTxt(dc.Records) // Autosplit long TXT records
|
||||
|
||||
var corrections []*models.Correction
|
||||
if !diff2.EnableDiff2 || true { // Remove "|| true" when diff2 version arrives
|
||||
|
||||
var create, del, modify diff.Changeset
|
||||
if !diff2.EnableDiff2 {
|
||||
differ := diff.New(dc)
|
||||
_, create, del, modify, err := differ.IncrementalDiff(existingRecords)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Deletes first so changing type works etc.
|
||||
for _, m := range del {
|
||||
req := m.Existing.Original.(*record)
|
||||
corr := &models.Correction{
|
||||
Msg: fmt.Sprintf("%s, Netcup ID: %s", m.String(), req.ID),
|
||||
F: func() error {
|
||||
return api.deleteRecord(domain, req)
|
||||
},
|
||||
}
|
||||
corrections = append(corrections, corr)
|
||||
}
|
||||
|
||||
for _, m := range create {
|
||||
req := fromRecordConfig(m.Desired)
|
||||
corr := &models.Correction{
|
||||
Msg: m.String(),
|
||||
F: func() error {
|
||||
return api.createRecord(domain, req)
|
||||
},
|
||||
}
|
||||
corrections = append(corrections, corr)
|
||||
}
|
||||
for _, m := range modify {
|
||||
id := m.Existing.Original.(*record).ID
|
||||
req := fromRecordConfig(m.Desired)
|
||||
req.ID = id
|
||||
corr := &models.Correction{
|
||||
Msg: fmt.Sprintf("%s, Netcup ID: %s: ", m.String(), id),
|
||||
F: func() error {
|
||||
return api.modifyRecord(domain, req)
|
||||
},
|
||||
}
|
||||
corrections = append(corrections, corr)
|
||||
}
|
||||
|
||||
return corrections, nil
|
||||
_, create, del, modify, err = differ.IncrementalDiff(existingRecords)
|
||||
} else {
|
||||
differ := diff.NewCompat(dc)
|
||||
_, create, del, modify, err = differ.IncrementalDiff(existingRecords)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Insert Future diff2 version here.
|
||||
// Deletes first so changing type works etc.
|
||||
for _, m := range del {
|
||||
req := m.Existing.Original.(*record)
|
||||
corr := &models.Correction{
|
||||
Msg: fmt.Sprintf("%s, Netcup ID: %s", m.String(), req.ID),
|
||||
F: func() error {
|
||||
return api.deleteRecord(domain, req)
|
||||
},
|
||||
}
|
||||
corrections = append(corrections, corr)
|
||||
}
|
||||
|
||||
for _, m := range create {
|
||||
req := fromRecordConfig(m.Desired)
|
||||
corr := &models.Correction{
|
||||
Msg: m.String(),
|
||||
F: func() error {
|
||||
return api.createRecord(domain, req)
|
||||
},
|
||||
}
|
||||
corrections = append(corrections, corr)
|
||||
}
|
||||
for _, m := range modify {
|
||||
id := m.Existing.Original.(*record).ID
|
||||
req := fromRecordConfig(m.Desired)
|
||||
req.ID = id
|
||||
corr := &models.Correction{
|
||||
Msg: fmt.Sprintf("%s, Netcup ID: %s: ", m.String(), id),
|
||||
F: func() error {
|
||||
return api.modifyRecord(domain, req)
|
||||
},
|
||||
}
|
||||
corrections = append(corrections, corr)
|
||||
}
|
||||
|
||||
return corrections, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user