Skip to content

Commit

Permalink
deadcode: RRstoRCs (moved)
Browse files Browse the repository at this point in the history
  • Loading branch information
tlimoncelli committed Mar 3, 2024
1 parent 15f7737 commit a3dad4d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
13 changes: 0 additions & 13 deletions models/dnsrr.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,6 @@ func (rc *RecordConfig) String() string {

// Conversions

// RRstoRCs converts []dns.RR to []RecordConfigs.
func RRstoRCs(rrs []dns.RR, origin string) (Records, error) {
rcs := make(Records, 0, len(rrs))
for _, r := range rrs {
rc, err := RRtoRC(r, origin)
if err != nil {
return nil, err
}

rcs = append(rcs, &rc)
}
return rcs, nil
}

// RRtoRC converts dns.RR to RecordConfig
func RRtoRC(rr dns.RR, origin string) (RecordConfig, error) {
Expand Down
26 changes: 20 additions & 6 deletions pkg/prettyzone/prettyzone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,23 @@ func parseAndRegen(t *testing.T, buf *bytes.Buffer, expected string) {
}
}

// rrstoRCs converts []dns.RR to []RecordConfigs.
func rrstoRCs(rrs []dns.RR, origin string) (models.Records, error) {
rcs := make(models.Records, 0, len(rrs))
for _, r := range rrs {
rc, err := models.RRtoRC(r, origin)
if err != nil {
return nil, err
}

rcs = append(rcs, &rc)
}
return rcs, nil
}

// writeZoneFileRR is a helper for when you have []dns.RR instead of models.Records
func writeZoneFileRR(w io.Writer, records []dns.RR, origin string) error {
rcs, err := models.RRstoRCs(records, origin)
rcs, err := rrstoRCs(records, origin)
if err != nil {
return err
}
Expand All @@ -59,7 +73,7 @@ func TestMostCommonTtl(t *testing.T) {
// All records are TTL=100
records = nil
records, e = append(records, r1, r1, r1), 100
x, err := models.RRstoRCs(records, "bosun.org")
x, err := rrstoRCs(records, "bosun.org")
if err != nil {
panic(err)
}
Expand All @@ -71,7 +85,7 @@ func TestMostCommonTtl(t *testing.T) {
// Mixture of TTLs with an obvious winner.
records = nil
records, e = append(records, r1, r2, r2), 200
rcs, err := models.RRstoRCs(records, "bosun.org")
rcs, err := rrstoRCs(records, "bosun.org")
if err != nil {
panic(err)
}
Expand All @@ -83,7 +97,7 @@ func TestMostCommonTtl(t *testing.T) {
// 3-way tie. Largest TTL should be used.
records = nil
records, e = append(records, r1, r2, r3), 300
rcs, err = models.RRstoRCs(records, "bosun.org")
rcs, err = rrstoRCs(records, "bosun.org")
if err != nil {
panic(err)
}
Expand All @@ -95,7 +109,7 @@ func TestMostCommonTtl(t *testing.T) {
// NS records are ignored.
records = nil
records, e = append(records, r1, r4, r5), 100
rcs, err = models.RRstoRCs(records, "bosun.org")
rcs, err = rrstoRCs(records, "bosun.org")
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -357,7 +371,7 @@ func TestWriteZoneFileSynth(t *testing.T) {
rsynz := &models.RecordConfig{Type: "R53_ALIAS", TTL: 300}
rsynz.SetLabel("zalias", "bosun.org")

recs, err := models.RRstoRCs([]dns.RR{r1, r2, r3}, "bosun.org")
recs, err := rrstoRCs([]dns.RR{r1, r2, r3}, "bosun.org")
if err != nil {
panic(err)
}
Expand Down

0 comments on commit a3dad4d

Please # to comment.