1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

PowerDNS: fix order problems of delete corrections & some cleanup (#1153)

Signed-off-by: Jan-Philipp Benecke <jan-philipp.benecke@jpbe.de>
This commit is contained in:
Jan-Philipp Benecke
2021-05-10 16:18:40 +02:00
committed by GitHub
parent 4458595333
commit cf8e288339
3 changed files with 34 additions and 43 deletions

View File

@@ -27,8 +27,6 @@ type Differ interface {
// ChangedGroups performs a diff more appropriate for providers with a "RecordSet" model, where all records with the same name and type are grouped.
// Individual record changes are often not useful in such scenarios. Instead we return a map of record keys to a list of change descriptions within that group.
ChangedGroups(existing []*models.RecordConfig) (map[models.RecordKey][]string, error)
// ChangedGroupsDeleteFirst is the same as ChangedGroups but it sorts the deletions to the first postion
ChangedGroupsDeleteFirst(existing []*models.RecordConfig) (map[models.RecordKey][]string, error)
}
// New is a constructor for a Differ.
@@ -315,24 +313,6 @@ func (d *differ) ChangedGroups(existing []*models.RecordConfig) (map[models.Reco
return changedKeys, nil
}
func (d *differ) ChangedGroupsDeleteFirst(existing []*models.RecordConfig) (map[models.RecordKey][]string, error) {
changedKeys := map[models.RecordKey][]string{}
_, create, toDelete, modify, err := d.IncrementalDiff(existing)
if err != nil {
return nil, err
}
for _, d := range toDelete {
changedKeys[d.Existing.Key()] = append(changedKeys[d.Existing.Key()], d.String())
}
for _, c := range create {
changedKeys[c.Desired.Key()] = append(changedKeys[c.Desired.Key()], c.String())
}
for _, m := range modify {
changedKeys[m.Desired.Key()] = append(changedKeys[m.Desired.Key()], m.String())
}
return changedKeys, nil
}
// DebugKeyMapMap debug prints the results from ChangedGroups.
func DebugKeyMapMap(note string, m map[models.RecordKey][]string) {
// The output isn't pretty but it is useful.