aboutsummaryrefslogtreecommitdiff
path: root/plugin/federation/setup.go
diff options
context:
space:
mode:
authorGravatar Yong Tang <yong.tang.github@outlook.com> 2019-08-18 14:41:51 -0700
committerGravatar GitHub <noreply@github.com> 2019-08-18 14:41:51 -0700
commit6402cef3371b6a5716dd032e2484d865cf25338a (patch)
tree3d53847a82db477f9e2e8dea16b0015d5695703e /plugin/federation/setup.go
parentbbf148360b2bd35b9a1e358fdf7984a33b15a8d5 (diff)
downloadcoredns-6402cef3371b6a5716dd032e2484d865cf25338a.tar.gz
coredns-6402cef3371b6a5716dd032e2484d865cf25338a.tar.zst
coredns-6402cef3371b6a5716dd032e2484d865cf25338a.zip
Move federation plugin to github.com/coredns/federation (#3139)
* Remove federation Signed-off-by: Yong Tang <yong.tang.github@outlook.com> * Rebuild and point to github.com/coredns/federation Signed-off-by: Yong Tang <yong.tang.github@outlook.com> * Export `localNodeName` => `LocalNodeName`, to be used by federation (until deprecation) Signed-off-by: Yong Tang <yong.tang.github@outlook.com> * Remove plugin/kubernetes/federation.go (=> kubernetes/federation repo) Signed-off-by: Yong Tang <yong.tang.github@outlook.com> * Update github.com/coredns/federation Signed-off-by: Yong Tang <yong.tang.github@outlook.com> * sticker-ci fix Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Diffstat (limited to 'plugin/federation/setup.go')
-rw-r--r--plugin/federation/setup.go94
1 files changed, 0 insertions, 94 deletions
diff --git a/plugin/federation/setup.go b/plugin/federation/setup.go
deleted file mode 100644
index fde50853d..000000000
--- a/plugin/federation/setup.go
+++ /dev/null
@@ -1,94 +0,0 @@
-package federation
-
-import (
- "fmt"
-
- "github.com/coredns/coredns/core/dnsserver"
- "github.com/coredns/coredns/plugin"
- "github.com/coredns/coredns/plugin/kubernetes"
- "github.com/coredns/coredns/plugin/pkg/upstream"
- "github.com/miekg/dns"
-
- "github.com/caddyserver/caddy"
-)
-
-func init() {
- caddy.RegisterPlugin("federation", caddy.Plugin{
- ServerType: "dns",
- Action: setup,
- })
-}
-
-func setup(c *caddy.Controller) error {
- fed, err := federationParse(c)
- if err != nil {
- return plugin.Error("federation", err)
- }
-
- // Do this in OnStartup, so all plugin has been initialized.
- c.OnStartup(func() error {
- m := dnsserver.GetConfig(c).Handler("kubernetes")
- if m == nil {
- return nil
- }
- if x, ok := m.(*kubernetes.Kubernetes); ok {
- fed.Federations = x.Federations
- }
- return nil
- })
-
- dnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler {
- fed.Next = next
- return fed
- })
-
- return nil
-}
-
-func federationParse(c *caddy.Controller) (*Federation, error) {
- fed := New()
- fed.Upstream = upstream.New()
-
- for c.Next() {
- // federation [zones..]
- zones := c.RemainingArgs()
- var origins []string
- if len(zones) > 0 {
- origins = make([]string, len(zones))
- copy(origins, zones)
- } else {
- origins = make([]string, len(c.ServerBlockKeys))
- copy(origins, c.ServerBlockKeys)
- }
-
- for c.NextBlock() {
- x := c.Val()
- switch x {
- case "upstream":
- // remove soon
- c.RemainingArgs()
- default:
- args := c.RemainingArgs()
- if x := len(args); x != 1 {
- return fed, fmt.Errorf("need two arguments for federation, got %d", x)
- }
-
- fed.f[x] = dns.Fqdn(args[0])
- }
- }
-
- for i := range origins {
- origins[i] = plugin.Host(origins[i]).Normalize()
- }
-
- fed.zones = origins
-
- if len(fed.f) == 0 {
- return fed, fmt.Errorf("at least one name to zone federation expected")
- }
-
- return fed, nil
- }
-
- return fed, nil
-}