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.
This commit is contained in:
Miek Gieben 2016-08-19 17:14:17 -07:00 committed by GitHub
parent a1989c3523
commit 9ac3cab1b7
140 changed files with 2058 additions and 8229 deletions

View file

@ -19,20 +19,19 @@ import (
"golang.org/x/net/context"
)
var (
etc *Etcd
client etcdc.KeysAPI
ctxt context.Context
)
func init() {
ctxt, _ = context.WithTimeout(context.Background(), etcdTimeout)
}
// etc *Etcd
func newEtcdMiddleware() *Etcd {
ctxt, _ = context.WithTimeout(context.Background(), etcdTimeout)
etcdCfg := etcdc.Config{
Endpoints: []string{"http://localhost:2379"},
}
cli, _ := etcdc.New(etcdCfg)
etc = &Etcd{
return &Etcd{
Proxy: proxy.New([]string{"8.8.8.8:53"}),
PathPrefix: "skydns",
Ctx: context.Background(),
@ -57,10 +56,12 @@ func delete(t *testing.T, e *Etcd, k string) {
}
func TestLookup(t *testing.T) {
etc := newEtcdMiddleware()
for _, serv := range services {
set(t, etc, serv.Key, 0, serv)
defer delete(t, etc, serv.Key)
}
for _, tc := range dnsTestCases {
m := tc.Msg()
@ -91,3 +92,5 @@ func TestLookup(t *testing.T) {
}
}
}
var ctxt context.Context