diff options
author | 2018-01-07 16:32:59 +0000 | |
---|---|---|
committer | 2018-01-07 16:32:59 +0000 | |
commit | c6febe6250361eee580dbb8a601a444f23ed7ac2 (patch) | |
tree | ee81ab66cfa382d66bc085d31804efb8c1059af2 /plugin/kubernetes | |
parent | 84ebbbc7225a8d7eb5e00c0c525f7e12932a9fe4 (diff) | |
download | coredns-c6febe6250361eee580dbb8a601a444f23ed7ac2.tar.gz coredns-c6febe6250361eee580dbb8a601a444f23ed7ac2.tar.zst coredns-c6febe6250361eee580dbb8a601a444f23ed7ac2.zip |
Add pkg/fall for Fallthrough (#1355)
* Add pkg/fall for Fallthrough
Move this into it's own package to facilitate tests. Important bug
was fixed: make the names fully qualified.
Add fall package to hosts, reverse, etcd, and fix kubernetes and any
tests. The k8s tests are still as-is, might need a future cleanup.
Diffstat (limited to 'plugin/kubernetes')
-rw-r--r-- | plugin/kubernetes/handler.go | 2 | ||||
-rw-r--r-- | plugin/kubernetes/kubernetes.go | 3 | ||||
-rw-r--r-- | plugin/kubernetes/setup.go | 5 | ||||
-rw-r--r-- | plugin/kubernetes/setup_test.go | 4 |
4 files changed, 8 insertions, 6 deletions
diff --git a/plugin/kubernetes/handler.go b/plugin/kubernetes/handler.go index 4606e3747..e02608a6b 100644 --- a/plugin/kubernetes/handler.go +++ b/plugin/kubernetes/handler.go @@ -59,7 +59,7 @@ func (k Kubernetes) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.M } if k.IsNameError(err) { - if plugin.Fallthrough(k.Fallthrough, state.Name()) { + if k.Fall.Through(state.Name()) { return plugin.NextOrFailure(k.Name(), k.Next, ctx, w, r) } return plugin.BackendError(&k, zone, dns.RcodeNameError, state, nil /* err */, plugin.Options{}) diff --git a/plugin/kubernetes/kubernetes.go b/plugin/kubernetes/kubernetes.go index 66821380e..a41397848 100644 --- a/plugin/kubernetes/kubernetes.go +++ b/plugin/kubernetes/kubernetes.go @@ -12,6 +12,7 @@ import ( "github.com/coredns/coredns/plugin" "github.com/coredns/coredns/plugin/etcd/msg" "github.com/coredns/coredns/plugin/pkg/dnsutil" + "github.com/coredns/coredns/plugin/pkg/fall" "github.com/coredns/coredns/plugin/pkg/healthcheck" "github.com/coredns/coredns/plugin/proxy" "github.com/coredns/coredns/request" @@ -40,7 +41,7 @@ type Kubernetes struct { Namespaces map[string]bool podMode string endpointNameMode bool - Fallthrough *[]string // nil = disabled, empty = all zones, o/w zones + Fall *fall.F ttl uint32 primaryZoneIndex int diff --git a/plugin/kubernetes/setup.go b/plugin/kubernetes/setup.go index 41727cb7e..f4de8d72a 100644 --- a/plugin/kubernetes/setup.go +++ b/plugin/kubernetes/setup.go @@ -10,6 +10,7 @@ import ( "github.com/coredns/coredns/core/dnsserver" "github.com/coredns/coredns/plugin" "github.com/coredns/coredns/plugin/pkg/dnsutil" + "github.com/coredns/coredns/plugin/pkg/fall" "github.com/coredns/coredns/plugin/proxy" "github.com/mholt/caddy" @@ -172,8 +173,8 @@ func kubernetesParse(c *caddy.Controller) (*Kubernetes, dnsControlOpts, error) { } return nil, opts, c.ArgErr() case "fallthrough": - zones := c.RemainingArgs() - k8s.Fallthrough = &zones + k8s.Fall = fall.New() + k8s.Fall.SetZones(c.RemainingArgs()) case "upstream": args := c.RemainingArgs() if len(args) == 0 { diff --git a/plugin/kubernetes/setup_test.go b/plugin/kubernetes/setup_test.go index 6f726c7c4..c7c6c15ce 100644 --- a/plugin/kubernetes/setup_test.go +++ b/plugin/kubernetes/setup_test.go @@ -347,7 +347,7 @@ func TestKubernetesParse(t *testing.T) { defaultResyncPeriod, "", podModeDisabled, - &[]string{"ip6.arpa", "inaddr.arpa", "foo.com"}, + &[]string{"ip6.arpa.", "inaddr.arpa.", "foo.com."}, nil, }, // Valid upstream @@ -443,7 +443,7 @@ func TestKubernetesParse(t *testing.T) { } // fallthrough - foundFallthrough := k8sController.Fallthrough + foundFallthrough := k8sController.Fall if foundFallthrough != nil { failed := false if test.expectedFallthrough == nil { |