From c6937b0bfcf8c200a7d0fdb698838e329d37b78c Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Fri, 15 Dec 2017 01:26:36 -0600 Subject: [PATCH] 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 --- core/dnsserver/register.go | 2 +- core/dnsserver/zdirectives.go | 3 +-- directives_generate.go | 3 +-- 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 {