aboutsummaryrefslogtreecommitdiff
path: root/core/setup/controller.go
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2016-08-19 17:14:17 -0700
committerGravatar GitHub <noreply@github.com> 2016-08-19 17:14:17 -0700
commit9ac3cab1b7b1b1e78f86ce3c6a80fbee312162e6 (patch)
tree437e9755927c33af16276ad2602a6da115f948cb /core/setup/controller.go
parenta1989c35231b0e5ea271b2f68d82c1a63e697cd0 (diff)
downloadcoredns-9ac3cab1b7b1b1e78f86ce3c6a80fbee312162e6.tar.gz
coredns-9ac3cab1b7b1b1e78f86ce3c6a80fbee312162e6.tar.zst
coredns-9ac3cab1b7b1b1e78f86ce3c6a80fbee312162e6.zip
Make CoreDNS a server type plugin for Caddy (#220)
* Make CoreDNS a server type plugin for Caddy Remove code we don't need and port all middleware over. Fix all tests and rework the documentation. Also make `go generate` build a caddy binary which we then copy into our directory. This means `go build`-builds remain working as-is. And new etc instances in each etcd test for better isolation. Fix more tests and rework test.Server with the newer support Caddy offers. Fix Makefile to support new mode of operation.
Diffstat (limited to 'core/setup/controller.go')
-rw-r--r--core/setup/controller.go85
1 files changed, 0 insertions, 85 deletions
diff --git a/core/setup/controller.go b/core/setup/controller.go
deleted file mode 100644
index 7f8da6721..000000000
--- a/core/setup/controller.go
+++ /dev/null
@@ -1,85 +0,0 @@
-package setup
-
-import (
- "fmt"
- "strings"
-
- "golang.org/x/net/context"
-
- "github.com/miekg/coredns/core/parse"
- "github.com/miekg/coredns/middleware"
- "github.com/miekg/coredns/server"
- "github.com/miekg/dns"
-)
-
-// Controller is given to the setup function of middlewares which
-// gives them access to be able to read tokens and set config. Each
-// virtualhost gets their own server config and dispenser.
-type Controller struct {
- *server.Config
- parse.Dispenser
-
- // OncePerServerBlock is a function that executes f
- // exactly once per server block, no matter how many
- // hosts are associated with it. If it is the first
- // time, the function f is executed immediately
- // (not deferred) and may return an error which is
- // returned by OncePerServerBlock.
- OncePerServerBlock func(f func() error) error
-
- // ServerBlockIndex is the 0-based index of the
- // server block as it appeared in the input.
- ServerBlockIndex int
-
- // ServerBlockHostIndex is the 0-based index of this
- // host as it appeared in the input at the head of the
- // server block.
- ServerBlockHostIndex int
-
- // ServerBlockHosts is a list of hosts that are
- // associated with this server block. All these
- // hosts, consequently, share the same tokens.
- ServerBlockHosts []string
-
- // ServerBlockStorage is used by a directive's
- // setup function to persist state between all
- // the hosts on a server block.
- ServerBlockStorage interface{}
-}
-
-// NewTestController creates a new *Controller for
-// the input specified, with a filename of "Testfile".
-// The Config is bare, consisting only of a Root of cwd.
-//
-// Used primarily for testing but needs to be exported so
-// add-ons can use this as a convenience. Does not initialize
-// the server-block-related fields.
-func NewTestController(input string) *Controller {
- return &Controller{
- Config: &server.Config{
- Root: ".",
- },
- Dispenser: parse.NewDispenser("Testfile", strings.NewReader(input)),
- OncePerServerBlock: func(f func() error) error {
- return f()
- },
- }
-}
-
-// EmptyNext is a no-op function that can be passed into
-// middleware.Middleware functions so that the assignment
-// to the Next field of the Handler can be tested.
-//
-// Used primarily for testing but needs to be exported so
-// add-ons can use this as a convenience.
-var EmptyNext = middleware.HandlerFunc(func(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) {
- return 0, nil
-})
-
-// SameNext does a pointer comparison between next1 and next2.
-//
-// Used primarily for testing but needs to be exported so
-// add-ons can use this as a convenience.
-func SameNext(next1, next2 middleware.Handler) bool {
- return fmt.Sprintf("%v", next1) == fmt.Sprintf("%v", next2)
-}