mirror of
https://github.com/coredns/coredns.git
synced 2025-12-09 11:55:13 -05:00
backend.Records make it take request.Request (#943)
This is more general and aligns well with the other methods. Also allows the kubernetes middleware to use it. Fixes #940
This commit is contained in:
@@ -37,7 +37,7 @@ type Etcd struct {
|
||||
|
||||
// Services implements the ServiceBackend interface.
|
||||
func (e *Etcd) Services(state request.Request, exact bool, opt middleware.Options) (services, debug []msg.Service, err error) {
|
||||
services, err = e.Records(state.Name(), exact)
|
||||
services, err = e.Records(state, exact)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -73,7 +73,9 @@ func (e *Etcd) Debug() string {
|
||||
|
||||
// Records looks up records in etcd. If exact is true, it will lookup just this
|
||||
// name. This is used when find matches when completing SRV lookups for instance.
|
||||
func (e *Etcd) Records(name string, exact bool) ([]msg.Service, error) {
|
||||
func (e *Etcd) Records(state request.Request, exact bool) ([]msg.Service, error) {
|
||||
name := state.Name()
|
||||
|
||||
path, star := msg.PathWithWildcard(name, e.PathPrefix)
|
||||
r, err := e.get(path, true)
|
||||
if err != nil {
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
"github.com/coredns/coredns/middleware/etcd/msg"
|
||||
"github.com/coredns/coredns/middleware/proxy"
|
||||
"github.com/coredns/coredns/request"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
)
|
||||
@@ -29,7 +30,11 @@ func (e *Etcd) UpdateStubZones() {
|
||||
// Only the first zone configured on e is used for the lookup.
|
||||
func (e *Etcd) updateStubZones() {
|
||||
zone := e.Zones[0]
|
||||
services, err := e.Records(stubDomain+"."+zone, false)
|
||||
|
||||
fakeState := request.Request{W: nil, Req: new(dns.Msg)}
|
||||
fakeState.Req.SetQuestion(stubDomain+"."+zone, dns.TypeA)
|
||||
|
||||
services, err := e.Records(fakeState, false)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user