aboutsummaryrefslogtreecommitdiff
path: root/middleware/autopath/autopath.go
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2017-08-10 19:26:31 +0100
committerGravatar GitHub <noreply@github.com> 2017-08-10 19:26:31 +0100
commit6cc3f47d466b7c6dda57d4fb8abb784dd278c495 (patch)
treec6d11c148fd91db91dab053226b6fff64daf4a5a /middleware/autopath/autopath.go
parent3654361be26d79e9b4a25581deb0168228022585 (diff)
downloadcoredns-6cc3f47d466b7c6dda57d4fb8abb784dd278c495.tar.gz
coredns-6cc3f47d466b7c6dda57d4fb8abb784dd278c495.tar.zst
coredns-6cc3f47d466b7c6dda57d4fb8abb784dd278c495.zip
middleware/authpath: Fix return from k8s mw (#871)
* middleware/authpath: Fix return from k8s mw Return the correct search path from the kubernetes' AutoPath function. Based on preliminary discussion in #870 * PodWithIP can be private Fix and add docs to functions. * CR: remove the error from AutoPathFunc
Diffstat (limited to 'middleware/autopath/autopath.go')
-rw-r--r--middleware/autopath/autopath.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/middleware/autopath/autopath.go b/middleware/autopath/autopath.go
index 31e8afd6d..ecbdf0464 100644
--- a/middleware/autopath/autopath.go
+++ b/middleware/autopath/autopath.go
@@ -27,8 +27,8 @@ AutoPathFunc. Note the searchpath must be ending with the empty string.
I.e:
-func (m Middleware ) AutoPath(state request.Request) ([]string, error) {
- return []string{"first", "second", "last", ""}, nil
+func (m Middleware ) AutoPath(state request.Request) []string {
+ return []string{"first", "second", "last", ""}
}
*/
@@ -45,8 +45,8 @@ import (
// AutoPathFunc defines the function middleware should implement to return a search
// path to the autopath middleware. The last element of the slice must be the empty string.
-// If AutoPathFunc returns a non-nil error no autopathing is performed.
-type AutoPathFunc func(request.Request) ([]string, error)
+// If AutoPathFunc returns a nil slice, no autopathing will be done.
+type AutoPathFunc func(request.Request) []string
// Autopath perform autopath: service side search path completion.
type AutoPath struct {
@@ -69,8 +69,8 @@ func (a *AutoPath) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Ms
var err error
searchpath := a.search
if a.searchFunc != nil {
- searchpath, err = a.searchFunc(state)
- if err != nil {
+ searchpath = a.searchFunc(state)
+ if len(searchpath) == 0 {
return middleware.NextOrFailure(a.Name(), a.Next, ctx, w, r)
}
}