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

Sort updates (cosmetic) (#772)

* Sort updates (cosmetic)

* comments

* More comments
This commit is contained in:
Tom Limoncelli
2020-07-01 05:55:20 -04:00
committed by GitHub
parent 0a36cb7fcc
commit 367a14ab44
4 changed files with 37 additions and 3 deletions

View File

@@ -4,6 +4,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"sort"
"github.com/StackExchange/dnscontrol/v3/models"
"github.com/StackExchange/dnscontrol/v3/pkg/diff"
@@ -215,5 +216,13 @@ func (c *api) GenerateDomainCorrections(dc *models.DomainConfig, existing models
},
})
// NB(tlim): This sort is just to make updates look pretty. It is
// cosmetic. The risk here is that there may be some updates that
// require a specific order (for example a delete before an add).
// However the code doesn't seem to have such situation. All tests
// pass. That said, if this breaks anything, the easiest fix might
// be to just remove the sort.
sort.Slice(corrections, func(i, j int) bool { return diff.CorrectionLess(corrections, i, j) })
return corrections, nil
}