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>
* Don't number the plugins
The number is not needed, because the ordering is already specified.
It's also annoying when you move plugins, because you need to renumber
them. Remove this.
'go gen' shows no changes in the generated files, meaning this just
works.
* better naming
* Rename middleware to plugin
first pass; mostly used 'sed', few spots where I manually changed
text.
This still builds a coredns binary.
* fmt error
* Rename AddMiddleware to AddPlugin
* Readd AddMiddleware to remain backwards compat
* Document fallthrough and fix *reverse*
While documenting the fallthrough behavior and testing it I noticed
the did not properly work. This PR does a tiny bit too much as it
- Documents fallthrough
- Fixes fallthrough in reverse
- Makes directives_generate complain on duplicate priorities
- Moved reverse *before* file in middleware.cfg
- Add a test that tests the reverse fallthrough behavior with a file
backend
Fixes#515
* ....and fix the tests
* all-middleware-equal
* Revert "all-middleware-equal"
This reverts commit ee77b2a981.
* middleware: treat external and local the same
Make the middleware generation simpler and also specify the local
middleware, meaning that it can now be removed as well. Simplify
the code a bit and regen everything.
* remove lineNR, not used
When using an external middleware, the generated file was failing to compile.
The issue is a typo in directives_generate.go that left imports with an
unterminated string.
Remove the "gen" directory and move directives_generate.go out of it.
Add a build ignore tag so it isn't build by default. Cleanup the go gen
invocations so there are not seen as package docs.
Simplify the code a bit and don't run go gen twice.