Browse Source

dns/show: introduce writeRecords() helper

to print a whole []libdns.Record

Signed-off-by: Alejandro Mery <amery@jpi.io>
pull/28/head
Alejandro Mery 8 months ago
parent
commit
356322bc94
  1. 10
      pkg/dns/show.go

10
pkg/dns/show.go

@ -14,20 +14,24 @@ import (
// Show shows current DNS entries
func (mgr *Manager) Show(ctx context.Context, names ...string) error {
var buf bytes.Buffer
recs, err := mgr.GetRecords(ctx, names...)
if err != nil {
return core.Wrap(err, "GetRecords")
}
return writeRecords(recs, os.Stdout)
}
func writeRecords(recs []libdns.Record, w io.Writer) error {
var buf bytes.Buffer
for _, rr := range recs {
_ = fmtRecord(&buf, rr)
_, _ = buf.WriteRune('\n')
}
_, _ = fmt.Fprintf(&buf, "; %v records\n", len(recs))
_, err = buf.WriteTo(os.Stdout)
_, err := buf.WriteTo(w)
return err
}

Loading…
Cancel
Save