mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
Refactor in preparation to unexport RecordConfig.{Name,NameFQDN,Target} (#337)
* Preparing for the unexport of Name/NameFQDN/Target * Cleanups
This commit is contained in:
@@ -178,7 +178,7 @@ func parseLeaf(results models.Records, k string, v interface{}, origin string) (
|
||||
case "port": // SRV
|
||||
newRc.SrvPort = uint16(v4.(int))
|
||||
case "value": // MX
|
||||
newRc.Target = v4.(string)
|
||||
newRc.SetTarget(v4.(string))
|
||||
}
|
||||
}
|
||||
//fmt.Printf("parseLeaf: append %v\n", newRc)
|
||||
|
@@ -56,7 +56,9 @@ func TestYamlWrite(t *testing.T) {
|
||||
m.AddFunc("json", minjson.Minify)
|
||||
|
||||
t.Run(f.Name(), func(t *testing.T) {
|
||||
content, err := ioutil.ReadFile(filepath.Join(testDir, f.Name()))
|
||||
fname := filepath.Join(testDir, f.Name())
|
||||
fmt.Printf("Filename: %v\n", fname)
|
||||
content, err := ioutil.ReadFile(fname)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@@ -48,14 +48,14 @@ func (z *genYamlData) Less(i, j int) bool {
|
||||
case "NS", "TXT", "TLSA":
|
||||
// pass through.
|
||||
case "A":
|
||||
ta2, tb2 := net.ParseIP(a.Target), net.ParseIP(b.Target)
|
||||
ta2, tb2 := net.ParseIP(a.GetTargetField()), net.ParseIP(b.GetTargetField())
|
||||
ipa, ipb := ta2.To4(), tb2.To4()
|
||||
if ipa == nil || ipb == nil {
|
||||
log.Fatalf("should not happen: IPs are not 4 bytes: %#v %#v", ta2, tb2)
|
||||
}
|
||||
return bytes.Compare(ipa, ipb) == -1
|
||||
case "AAAA":
|
||||
ta2, tb2 := net.ParseIP(a.Target), net.ParseIP(b.Target)
|
||||
ta2, tb2 := net.ParseIP(a.GetTargetField()), net.ParseIP(b.GetTargetField())
|
||||
ipa, ipb := ta2.To16(), tb2.To16()
|
||||
return bytes.Compare(ipa, ipb) == -1
|
||||
case "MX":
|
||||
@@ -75,7 +75,7 @@ func (z *genYamlData) Less(i, j int) bool {
|
||||
return pa < pb
|
||||
}
|
||||
case "PTR":
|
||||
pa, pb := a.Target, b.Target
|
||||
pa, pb := a.GetTargetField(), b.GetTargetField()
|
||||
if pa != pb {
|
||||
return pa < pb
|
||||
}
|
||||
|
@@ -28,8 +28,9 @@ func WriteYaml(w io.Writer, records models.Records, origin string) error {
|
||||
recsCopy = append(recsCopy, r)
|
||||
}
|
||||
for _, r := range recsCopy {
|
||||
if r.Name == "@" {
|
||||
r.Name = ""
|
||||
if r.GetLabel() == "@" {
|
||||
//r.Name = ""
|
||||
r.UnsafeSetLabelNull()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,7 +157,7 @@ func sameType(records models.Records) bool {
|
||||
func oneLabel(records models.Records) yaml.MapItem {
|
||||
item := yaml.MapItem{
|
||||
// a yaml.MapItem is a YAML map that retains the key order.
|
||||
Key: records[0].Name,
|
||||
Key: records[0].GetLabel(),
|
||||
}
|
||||
// Special case labels with a single record:
|
||||
if len(records) == 1 {
|
||||
|
Reference in New Issue
Block a user