aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Yong Tang <yong.tang.github@outlook.com> 2017-12-15 01:26:36 -0600
committerGravatar Miek Gieben <miek@miek.nl> 2017-12-15 07:26:36 +0000
commitc6937b0bfcf8c200a7d0fdb698838e329d37b78c (patch)
tree699ebc04d027321c0654b22b56911995f219b3be
parentcee6f60ab870a235dc7e052a4b5e4e7e64643f62 (diff)
downloadcoredns-c6937b0bfcf8c200a7d0fdb698838e329d37b78c.tar.gz
coredns-c6937b0bfcf8c200a7d0fdb698838e329d37b78c.tar.zst
coredns-c6937b0bfcf8c200a7d0fdb698838e329d37b78c.zip
Expose directives in dnsserver to help external plugin developers (#1315)
This fix expose directives in dnsserver package, so that external plugin developers could easily build customerized coredns+plugin without changing the code base tree of coredns. The following is an example that could bundle coredns+example, in one simple file without modifying coredns codebase: ``` package main import ( _ "github.com/coredns/example" "github.com/coredns/coredns/coremain" "github.com/coredns/coredns/core/dnsserver" ) var directives = []string{ "example", "log", "errors", ... ... ... "whoami", "startup", "shutdown", } func init() { dnsserver.Directives = directives } func main() { coremain.Run() } ``` Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
-rw-r--r--core/dnsserver/register.go2
-rw-r--r--core/dnsserver/zdirectives.go3
-rw-r--r--directives_generate.go3
3 files changed, 3 insertions, 5 deletions
diff --git a/core/dnsserver/register.go b/core/dnsserver/register.go
index e3fd19c75..44300d691 100644
--- a/core/dnsserver/register.go
+++ b/core/dnsserver/register.go
@@ -22,7 +22,7 @@ func init() {
flag.StringVar(&Port, serverType+".port", DefaultPort, "Default port")
caddy.RegisterServerType(serverType, caddy.ServerType{
- Directives: func() []string { return directives },
+ Directives: func() []string { return Directives },
DefaultInput: func() caddy.Input {
return caddy.CaddyfileInput{
Filepath: "Corefile",
diff --git a/core/dnsserver/zdirectives.go b/core/dnsserver/zdirectives.go
index d7874f17b..6af3639ed 100644
--- a/core/dnsserver/zdirectives.go
+++ b/core/dnsserver/zdirectives.go
@@ -9,8 +9,7 @@ package dnsserver
// feel the effects of all other plugin below
// (after) them during a request, but they must not
// care what plugin above them are doing.
-
-var directives = []string{
+var Directives = []string{
"tls",
"nsid",
"root",
diff --git a/directives_generate.go b/directives_generate.go
index b67e6dea5..ece92e329 100644
--- a/directives_generate.go
+++ b/directives_generate.go
@@ -81,8 +81,7 @@ func genDirectives(file, pack string, md []string) {
// feel the effects of all other plugin below
// (after) them during a request, but they must not
// care what plugin above them are doing.
-
-var directives = []string{
+var Directives = []string{
`
for i := range md {