mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
deadcode: Change/ChangeList.String
This commit is contained in:
@ -1,6 +1,8 @@
|
|||||||
package diff2
|
package diff2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@ -18,6 +20,42 @@ func init() {
|
|||||||
color.NoColor = true
|
color.NoColor = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Stringify the datastructures (for debugging)
|
||||||
|
|
||||||
|
func (c Change) String() string {
|
||||||
|
var buf bytes.Buffer
|
||||||
|
b := &buf
|
||||||
|
|
||||||
|
fmt.Fprintf(b, "Change: verb=%v\n", c.Type)
|
||||||
|
fmt.Fprintf(b, " key=%v\n", c.Key)
|
||||||
|
if c.HintOnlyTTL {
|
||||||
|
fmt.Fprint(b, " Hints=OnlyTTL\n", c.Key)
|
||||||
|
}
|
||||||
|
if len(c.Old) != 0 {
|
||||||
|
fmt.Fprintf(b, " old=%v\n", c.Old)
|
||||||
|
}
|
||||||
|
if len(c.New) != 0 {
|
||||||
|
fmt.Fprintf(b, " new=%v\n", c.New)
|
||||||
|
}
|
||||||
|
fmt.Fprintf(b, " msg=%q\n", c.Msgs)
|
||||||
|
|
||||||
|
return b.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cl ChangeList) String() string {
|
||||||
|
var buf bytes.Buffer
|
||||||
|
b := &buf
|
||||||
|
|
||||||
|
fmt.Fprintf(b, "ChangeList: len=%d\n", len(cl))
|
||||||
|
for i, j := range cl {
|
||||||
|
fmt.Fprintf(b, "%02d: %s", i, j)
|
||||||
|
}
|
||||||
|
|
||||||
|
return b.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sample data
|
||||||
|
|
||||||
func makeRec(label, rtype, content string) *models.RecordConfig {
|
func makeRec(label, rtype, content string) *models.RecordConfig {
|
||||||
origin := "f.com"
|
origin := "f.com"
|
||||||
r := models.RecordConfig{TTL: 300}
|
r := models.RecordConfig{TTL: 300}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package diff2
|
package diff2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
@ -171,35 +170,6 @@ func (cc *CompareConfig) verifyCNAMEAssertions() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// String returns cc represented as a string. This is used for
|
|
||||||
// debugging and unit tests, as the structure may otherwise be
|
|
||||||
// difficult to compare.
|
|
||||||
func (cc *CompareConfig) String() string {
|
|
||||||
var buf bytes.Buffer
|
|
||||||
b := &buf
|
|
||||||
|
|
||||||
fmt.Fprintf(b, "ldata:\n")
|
|
||||||
for i, ld := range cc.ldata {
|
|
||||||
fmt.Fprintf(b, " ldata[%02d]: %s\n", i, ld.label)
|
|
||||||
for j, t := range ld.tdata {
|
|
||||||
fmt.Fprintf(b, " tdata[%d]: %q e(%d, %d) d(%d, %d)\n", j, t.rType,
|
|
||||||
len(t.existingTargets),
|
|
||||||
len(t.existingRecs),
|
|
||||||
len(t.desiredTargets),
|
|
||||||
len(t.desiredRecs),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fmt.Fprintf(b, "labelMap: len=%d %v\n", len(cc.labelMap), cc.labelMap)
|
|
||||||
fmt.Fprintf(b, "keyMap: len=%d %v\n", len(cc.keyMap), cc.keyMap)
|
|
||||||
fmt.Fprintf(b, "existing: %q\n", cc.existing)
|
|
||||||
fmt.Fprintf(b, "desired: %q\n", cc.desired)
|
|
||||||
fmt.Fprintf(b, "origin: %v\n", cc.origin)
|
|
||||||
fmt.Fprintf(b, "compFn: %v\n", cc.compareableFunc)
|
|
||||||
|
|
||||||
return b.String()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate a string that can be used to compare this record to others
|
// Generate a string that can be used to compare this record to others
|
||||||
// for equality.
|
// for equality.
|
||||||
func mkCompareBlobs(rc *models.RecordConfig, f func(*models.RecordConfig) string) (string, string) {
|
func mkCompareBlobs(rc *models.RecordConfig, f func(*models.RecordConfig) string) (string, string) {
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package diff2
|
package diff2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -8,6 +10,35 @@ import (
|
|||||||
"github.com/kylelemons/godebug/diff"
|
"github.com/kylelemons/godebug/diff"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// String returns cc represented as a string. This is used for
|
||||||
|
// debugging and unit tests, as the structure may otherwise be
|
||||||
|
// difficult to compare.
|
||||||
|
func (cc *CompareConfig) String() string {
|
||||||
|
var buf bytes.Buffer
|
||||||
|
b := &buf
|
||||||
|
|
||||||
|
fmt.Fprintf(b, "ldata:\n")
|
||||||
|
for i, ld := range cc.ldata {
|
||||||
|
fmt.Fprintf(b, " ldata[%02d]: %s\n", i, ld.label)
|
||||||
|
for j, t := range ld.tdata {
|
||||||
|
fmt.Fprintf(b, " tdata[%d]: %q e(%d, %d) d(%d, %d)\n", j, t.rType,
|
||||||
|
len(t.existingTargets),
|
||||||
|
len(t.existingRecs),
|
||||||
|
len(t.desiredTargets),
|
||||||
|
len(t.desiredRecs),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fmt.Fprintf(b, "labelMap: len=%d %v\n", len(cc.labelMap), cc.labelMap)
|
||||||
|
fmt.Fprintf(b, "keyMap: len=%d %v\n", len(cc.keyMap), cc.keyMap)
|
||||||
|
fmt.Fprintf(b, "existing: %q\n", cc.existing)
|
||||||
|
fmt.Fprintf(b, "desired: %q\n", cc.desired)
|
||||||
|
fmt.Fprintf(b, "origin: %v\n", cc.origin)
|
||||||
|
fmt.Fprintf(b, "compFn: %v\n", cc.compareableFunc)
|
||||||
|
|
||||||
|
return b.String()
|
||||||
|
}
|
||||||
|
|
||||||
func TestNewCompareConfig(t *testing.T) {
|
func TestNewCompareConfig(t *testing.T) {
|
||||||
type args struct {
|
type args struct {
|
||||||
origin string
|
origin string
|
||||||
|
@ -6,7 +6,6 @@ package diff2
|
|||||||
// against the desired records.
|
// against the desired records.
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -255,37 +254,3 @@ func byHelper(fn func(cc *CompareConfig) ChangeList, existing models.Records, dc
|
|||||||
|
|
||||||
return instructions, nil
|
return instructions, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stringify the datastructures (for debugging)
|
|
||||||
|
|
||||||
func (c Change) String() string {
|
|
||||||
var buf bytes.Buffer
|
|
||||||
b := &buf
|
|
||||||
|
|
||||||
fmt.Fprintf(b, "Change: verb=%v\n", c.Type)
|
|
||||||
fmt.Fprintf(b, " key=%v\n", c.Key)
|
|
||||||
if c.HintOnlyTTL {
|
|
||||||
fmt.Fprint(b, " Hints=OnlyTTL\n", c.Key)
|
|
||||||
}
|
|
||||||
if len(c.Old) != 0 {
|
|
||||||
fmt.Fprintf(b, " old=%v\n", c.Old)
|
|
||||||
}
|
|
||||||
if len(c.New) != 0 {
|
|
||||||
fmt.Fprintf(b, " new=%v\n", c.New)
|
|
||||||
}
|
|
||||||
fmt.Fprintf(b, " msg=%q\n", c.Msgs)
|
|
||||||
|
|
||||||
return b.String()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (cl ChangeList) String() string {
|
|
||||||
var buf bytes.Buffer
|
|
||||||
b := &buf
|
|
||||||
|
|
||||||
fmt.Fprintf(b, "ChangeList: len=%d\n", len(cl))
|
|
||||||
for i, j := range cl {
|
|
||||||
fmt.Fprintf(b, "%02d: %s", i, j)
|
|
||||||
}
|
|
||||||
|
|
||||||
return b.String()
|
|
||||||
}
|
|
||||||
|
Reference in New Issue
Block a user