aboutsummaryrefslogtreecommitdiff
path: root/plugin/autopath/setup.go
diff options
context:
space:
mode:
authorGravatar James Hartig <fastest963@gmail.com> 2017-12-12 15:40:30 -0500
committerGravatar Miek Gieben <miek@miek.nl> 2017-12-12 20:40:30 +0000
commita469a17cdfccfb435f819ebdf7ff7b43b207c8b4 (patch)
tree7fefd2e00383f8b920826af4f1f42706e0ebe82e /plugin/autopath/setup.go
parent99e163c37511ce48eaa7c86ba7791937e32e0a52 (diff)
downloadcoredns-a469a17cdfccfb435f819ebdf7ff7b43b207c8b4.tar.gz
coredns-a469a17cdfccfb435f819ebdf7ff7b43b207c8b4.tar.zst
coredns-a469a17cdfccfb435f819ebdf7ff7b43b207c8b4.zip
Instead of hardcoding plugin lists in autopath/health, use interfaces. (#1306)
Switched health and autopath plugin to allow any plugins to be used instead of a hardcoded list. I did not switch federation over since it wasn't obvious that anything other than kubernetes could be used with it. Fixes #1291
Diffstat (limited to 'plugin/autopath/setup.go')
-rw-r--r--plugin/autopath/setup.go20
1 files changed, 4 insertions, 16 deletions
diff --git a/plugin/autopath/setup.go b/plugin/autopath/setup.go
index 42b4b317a..f4b908465 100644
--- a/plugin/autopath/setup.go
+++ b/plugin/autopath/setup.go
@@ -5,8 +5,6 @@ import (
"github.com/coredns/coredns/core/dnsserver"
"github.com/coredns/coredns/plugin"
- "github.com/coredns/coredns/plugin/erratic"
- "github.com/coredns/coredns/plugin/kubernetes"
"github.com/mholt/caddy"
"github.com/miekg/dns"
@@ -34,11 +32,10 @@ func setup(c *caddy.Controller) error {
if m == nil {
return nil
}
- if x, ok := m.(*kubernetes.Kubernetes); ok {
- ap.searchFunc = x.AutoPath
- }
- if x, ok := m.(*erratic.Erratic); ok {
+ if x, ok := m.(AutoPather); ok {
ap.searchFunc = x.AutoPath
+ } else {
+ return plugin.Error("autopath", fmt.Errorf("%s does not implement the AutoPather interface", mw))
}
return nil
})
@@ -51,12 +48,6 @@ func setup(c *caddy.Controller) error {
return nil
}
-// allowedPlugins has a list of plugin that can be used by autopath.
-var allowedPlugins = map[string]bool{
- "@kubernetes": true,
- "@erratic": true,
-}
-
func autoPathParse(c *caddy.Controller) (*AutoPath, string, error) {
ap := &AutoPath{}
mw := ""
@@ -68,10 +59,7 @@ func autoPathParse(c *caddy.Controller) (*AutoPath, string, error) {
}
resolv := zoneAndresolv[len(zoneAndresolv)-1]
if resolv[0] == '@' {
- _, ok := allowedPlugins[resolv]
- if ok {
- mw = resolv[1:]
- }
+ mw = resolv[1:]
} else {
// assume file on disk
rc, err := dns.ClientConfigFromFile(resolv)