ServiceBackend interface (#369)
* Add ServiceBackend interface This adds a ServiceBackend interface that is shared between etcd/etcd3 (later) and kubernetes, leading to a massive reduction in code. When returning the specific records from their backend. Fixes #273
This commit is contained in:
parent
81d5baee28
commit
27d893cf33
15 changed files with 273 additions and 503 deletions
|
@ -1,12 +1,6 @@
|
|||
package etcd
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/miekg/coredns/middleware/etcd/msg"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
)
|
||||
import "strings"
|
||||
|
||||
const debugName = "o-o.debug."
|
||||
|
||||
|
@ -24,34 +18,3 @@ func isDebug(name string) string {
|
|||
}
|
||||
return name[len(debugName):]
|
||||
}
|
||||
|
||||
// servicesToTxt puts debug in TXT RRs.
|
||||
func servicesToTxt(debug []msg.Service) []dns.RR {
|
||||
if debug == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
rr := make([]dns.RR, len(debug))
|
||||
for i, d := range debug {
|
||||
rr[i] = d.RR()
|
||||
}
|
||||
return rr
|
||||
}
|
||||
|
||||
func errorToTxt(err error) dns.RR {
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
msg := err.Error()
|
||||
if len(msg) > 255 {
|
||||
msg = msg[:255]
|
||||
}
|
||||
t := new(dns.TXT)
|
||||
t.Hdr.Class = dns.ClassCHAOS
|
||||
t.Hdr.Ttl = 0
|
||||
t.Hdr.Rrtype = dns.TypeTXT
|
||||
t.Hdr.Name = "."
|
||||
|
||||
t.Txt = []string{msg}
|
||||
return t
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue