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

REFACTOR: Add Joined and Segmented accessors to TXT, and other cleanups (#2628)

This commit is contained in:
Tom Limoncelli
2023-11-18 10:37:46 -05:00
committed by GitHub
parent 32fe2753d8
commit 8040e7bba2
10 changed files with 31 additions and 114 deletions

View File

@ -32,37 +32,6 @@ func (d *differ) content(r *models.RecordConfig) string {
return r.ToDiffable()
}
// ChangesetLess returns true if c[i] < c[j].
func ChangesetLess(c Changeset, i, j int) bool {
var a, b string
// Which fields are we comparing?
// Usually only Desired OR Existing content exists (we're either
// adding or deleting records). In those cases, just use whichever
// isn't nil.
// In the case where both Desired AND Existing exist, it doesn't
// matter which we use as long as we are consistent. I flipped a
// coin and picked to use Desired in that case.
if c[i].Desired != nil {
a = c[i].Desired.NameFQDN
} else {
a = c[i].Existing.NameFQDN
}
if c[j].Desired != nil {
b = c[j].Desired.NameFQDN
} else {
b = c[j].Existing.NameFQDN
}
return a < b
// TODO(tlim): This won't correctly sort:
// []string{"example.com", "foo.example.com", "bar.example.com"}
// A simple way to do that correctly is to split on ".", reverse the
// elements, and sort on the result.
}
// CorrectionLess returns true when comparing corrections.
func CorrectionLess(c []*models.Correction, i, j int) bool {
return c[i].Msg < c[j].Msg