mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
POWERDNS: Some minor fixes for ALIAS and TXTMulti and integration testing (#1065)
* POWERDNS: Some minor fixes for ALIAS and integration testing * POWERDNS: Readd missing error handling
This commit is contained in:
committed by
GitHub
parent
54bca37900
commit
06a1cc3d38
@ -27,6 +27,8 @@ 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.
|
||||
@ -262,14 +264,14 @@ func CorrectionLess(c []*models.Correction, i, j int) bool {
|
||||
|
||||
func (d *differ) ChangedGroups(existing []*models.RecordConfig) (map[models.RecordKey][]string, error) {
|
||||
changedKeys := map[models.RecordKey][]string{}
|
||||
_, create, delete, modify, err := d.IncrementalDiff(existing)
|
||||
_, create, toDelete, modify, err := d.IncrementalDiff(existing)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, c := range create {
|
||||
changedKeys[c.Desired.Key()] = append(changedKeys[c.Desired.Key()], c.String())
|
||||
}
|
||||
for _, d := range delete {
|
||||
for _, d := range toDelete {
|
||||
changedKeys[d.Existing.Key()] = append(changedKeys[d.Existing.Key()], d.String())
|
||||
}
|
||||
for _, m := range modify {
|
||||
@ -278,6 +280,24 @@ 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.
|
||||
|
Reference in New Issue
Block a user