diff options
Diffstat (limited to 'middleware/autopath/setup.go')
-rw-r--r-- | middleware/autopath/setup.go | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/middleware/autopath/setup.go b/middleware/autopath/setup.go index 804b61855..1855dd440 100644 --- a/middleware/autopath/setup.go +++ b/middleware/autopath/setup.go @@ -5,6 +5,7 @@ import ( "github.com/coredns/coredns/core/dnsserver" "github.com/coredns/coredns/middleware" + "github.com/coredns/coredns/middleware/kubernetes" "github.com/mholt/caddy" "github.com/miekg/dns" @@ -19,23 +20,21 @@ func init() { } func setup(c *caddy.Controller) error { - ap, _, err := autoPathParse(c) + ap, mw, err := autoPathParse(c) if err != nil { return middleware.Error("autopath", err) } + // Do this in OnStartup, so all middleware has been initialized. c.OnStartup(func() error { - // Do this in OnStartup, so all middleware has been initialized. // TODO(miek): fabricate test to proof this is not thread safe. - // TODO(miek): disable this for now: See https://github.com/coredns/coredns/issues/881 - /* - switch mw { - case "kubernetes": - if k, ok := m.(kubernetes.Kubernetes); ok { - ap.searchFunc = k.AutoPath - } - } - */ + m := dnsserver.GetConfig(c).GetHandler(mw) + if m == nil { + return nil + } + if k, ok := m.(kubernetes.Kubernetes); ok { + ap.searchFunc = k.AutoPath + } return nil }) @@ -47,6 +46,8 @@ func setup(c *caddy.Controller) error { return nil } +// allowedMiddleware has a list of middleware that can be used by autopath. For this to work, they +// need to register themselves with dnsserver.RegisterHandler. var allowedMiddleware = map[string]bool{ "@kubernetes": true, } |