mirror of
https://github.com/coredns/coredns.git
synced 2025-10-28 16:54:15 -04:00
mw/federation: add federation back as separate mw for k8s (#929)
* mw/federaration This PR add the federation back as a middleware to keep it more contained from the main kubernetes code. It also makes parseRequest less import and pushes this functionlity down in the k.Entries. This minimizes (or tries to) the importance for the qtype in the query. In the end the qtype checking should only happen in ServeDNS - but for k8s this might proof difficult. Numerous other cleanup in code and kubernetes tests. * up test coverage
This commit is contained in:
@@ -25,24 +25,17 @@ type recordRequest struct {
|
||||
|
||||
// parseRequest parses the qname to find all the elements we need for querying k8s.
|
||||
func (k *Kubernetes) parseRequest(state request.Request) (r recordRequest, err error) {
|
||||
// 3 Possible cases: TODO(chris): remove federations comments here.
|
||||
// SRV Request: _port._protocol.service.namespace.[federation.]type.zone
|
||||
// A Request (endpoint): endpoint.service.namespace.[federation.]type.zone
|
||||
// A Request (service): service.namespace.[federation.]type.zone
|
||||
// 3 Possible cases:
|
||||
// o SRV Request: _port._protocol.service.namespace.type.zone
|
||||
// o A Request (endpoint): endpoint.service.namespace.type.zone
|
||||
// o A Request (service): service.namespace.type.zone
|
||||
// Federations are handled in the federation middleware.
|
||||
|
||||
base, _ := dnsutil.TrimZone(state.Name(), state.Zone)
|
||||
segs := dns.SplitDomainName(base)
|
||||
|
||||
r.zone = state.Zone
|
||||
|
||||
if state.QType() == dns.TypeNS {
|
||||
return r, nil
|
||||
}
|
||||
|
||||
if state.QType() == dns.TypeA && isDefaultNS(state.Name(), r) {
|
||||
return r, nil
|
||||
}
|
||||
|
||||
offset := 0
|
||||
if state.QType() == dns.TypeSRV {
|
||||
// The kubernetes peer-finder expects queries with empty port and service to resolve
|
||||
@@ -99,8 +92,7 @@ func (k *Kubernetes) parseRequest(state request.Request) (r recordRequest, err e
|
||||
return r, errInvalidRequest
|
||||
}
|
||||
|
||||
// String return a string representation of r, it just returns all
|
||||
// fields concatenated with dots.
|
||||
// String return a string representation of r, it just returns all fields concatenated with dots.
|
||||
// This is mostly used in tests.
|
||||
func (r recordRequest) String() string {
|
||||
s := r.port
|
||||
|
||||
Reference in New Issue
Block a user