middleware/backend: add Records() to ServiceBackend interface (#770)
This commit is contained in:
parent
7fada97ee3
commit
ade7603021
3 changed files with 14 additions and 5 deletions
|
@ -25,6 +25,10 @@ type ServiceBackend interface {
|
||||||
|
|
||||||
// Debug returns a string used when returning debug services.
|
// Debug returns a string used when returning debug services.
|
||||||
Debug() string
|
Debug() string
|
||||||
|
|
||||||
|
// Returns _all_ services that matches a certain name.
|
||||||
|
// Note: it does not implement a specific service.
|
||||||
|
Records(name string, exact bool) ([]msg.Service, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Options are extra options that can be specified for a lookup.
|
// Options are extra options that can be specified for a lookup.
|
||||||
|
|
|
@ -124,10 +124,10 @@ func (k *Kubernetes) Services(state request.Request, exact bool, opt middleware.
|
||||||
svcs = append(svcs, k.defaultNSMsg(r))
|
svcs = append(svcs, k.defaultNSMsg(r))
|
||||||
return svcs, nil, nil
|
return svcs, nil, nil
|
||||||
}
|
}
|
||||||
s, e := k.Records(r)
|
s, e := k.Entries(r)
|
||||||
return s, nil, e // Haven't implemented debug queries yet.
|
return s, nil, e // Haven't implemented debug queries yet.
|
||||||
case "SRV":
|
case "SRV":
|
||||||
s, e := k.Records(r)
|
s, e := k.Entries(r)
|
||||||
// SRV for external services is not yet implemented, so remove those records
|
// SRV for external services is not yet implemented, so remove those records
|
||||||
noext := []msg.Service{}
|
noext := []msg.Service{}
|
||||||
for _, svc := range s {
|
for _, svc := range s {
|
||||||
|
@ -347,10 +347,15 @@ func (k *Kubernetes) parseRequest(lowerCasedName string, qtype uint16) (r record
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Records looks up services in kubernetes. If exact is true, it will lookup
|
// Records not implemented, see Entries().
|
||||||
|
func (k *Kubernetes) Records(name string, exact bool) ([]msg.Service, error) {
|
||||||
|
return nil, fmt.Errorf("NOOP")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Entries looks up services in kubernetes. If exact is true, it will lookup
|
||||||
// just this name. This is used when find matches when completing SRV lookups
|
// just this name. This is used when find matches when completing SRV lookups
|
||||||
// for instance.
|
// for instance.
|
||||||
func (k *Kubernetes) Records(r recordRequest) ([]msg.Service, error) {
|
func (k *Kubernetes) Entries(r recordRequest) ([]msg.Service, error) {
|
||||||
|
|
||||||
// Abort if the namespace does not contain a wildcard, and namespace is not published per CoreFile
|
// Abort if the namespace does not contain a wildcard, and namespace is not published per CoreFile
|
||||||
// Case where namespace contains a wildcard is handled in Get(...) method.
|
// Case where namespace contains a wildcard is handled in Get(...) method.
|
||||||
|
|
|
@ -16,7 +16,7 @@ func (k Kubernetes) records(state request.Request, exact bool) ([]msg.Service, e
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
services, err := k.Records(r)
|
services, err := k.Entries(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue