All middleware equal (#535)

* 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
This commit is contained in:
Miek Gieben 2017-02-19 20:34:29 +00:00 committed by GitHub
parent bcd9c8b0fb
commit ea38b642b8
4 changed files with 66 additions and 44 deletions

View file

@ -30,7 +30,6 @@ var directives = []string{
"kubernetes", "kubernetes",
"reverse", "reverse",
"proxy", "proxy",
"httpprox",
"whoami", "whoami",
"erratic", "erratic",
} }

View file

@ -1,4 +1,27 @@
// generated by directives_generate.go; DO NOT EDIT // generated by directives_generate.go; DO NOT EDIT
package core package core
import () import (
_ "github.com/miekg/coredns/middleware/auto"
_ "github.com/miekg/coredns/middleware/bind"
_ "github.com/miekg/coredns/middleware/cache"
_ "github.com/miekg/coredns/middleware/chaos"
_ "github.com/miekg/coredns/middleware/dnssec"
_ "github.com/miekg/coredns/middleware/erratic"
_ "github.com/miekg/coredns/middleware/errors"
_ "github.com/miekg/coredns/middleware/etcd"
_ "github.com/miekg/coredns/middleware/file"
_ "github.com/miekg/coredns/middleware/health"
_ "github.com/miekg/coredns/middleware/kubernetes"
_ "github.com/miekg/coredns/middleware/loadbalance"
_ "github.com/miekg/coredns/middleware/log"
_ "github.com/miekg/coredns/middleware/metrics"
_ "github.com/miekg/coredns/middleware/pprof"
_ "github.com/miekg/coredns/middleware/proxy"
_ "github.com/miekg/coredns/middleware/reverse"
_ "github.com/miekg/coredns/middleware/rewrite"
_ "github.com/miekg/coredns/middleware/root"
_ "github.com/miekg/coredns/middleware/secondary"
_ "github.com/miekg/coredns/middleware/trace"
_ "github.com/miekg/coredns/middleware/whoami"
)

View file

@ -25,22 +25,23 @@ func main() {
scanner := bufio.NewScanner(file) scanner := bufio.NewScanner(file)
for scanner.Scan() { for scanner.Scan() {
line := scanner.Text() line := scanner.Text()
if !strings.HasPrefix(line, `//`) && !strings.HasPrefix(line, "#") { if strings.HasPrefix(line, "#") {
continue
}
items := strings.Split(line, ":") items := strings.Split(line, ":")
if len(items) == 3 { if len(items) != 3 {
if priority, err := strconv.Atoi(items[0]); err == nil { // ignore
continue
}
priority, err := strconv.Atoi(items[0])
fatalIfErr(err)
md[priority] = items[1] md[priority] = items[1]
} mi[items[1]] = middlewarePath + items[2] // Default, unless overriden by 3rd arg
if items[2] != "" { if strings.Contains(items[2], "/") { // External package has been given
if strings.Contains(items[2], "/") {
mi[items[1]] = items[2] mi[items[1]] = items[2]
} else {
mi[items[1]] = middlewarePath + items[2]
}
}
}
} }
} }

View file

@ -6,39 +6,38 @@
# (after) them during a request, but they must not # (after) them during a request, but they must not
# care what middleware above them are doing. # care what middleware above them are doing.
# How to rebuild with updated middleware configurations: # How to rebuild with updated middleware configurations:
# Modify the list below and run `make gen && make` # Modify the list below and run `go gen && go build`
# The parser takes the input format of # The parser takes the input format of
# <order>:<middleware-name>:<package-name> # <order>:<middleware-name>:<package-name>
# OR # Or
# <order>:<middleware-name>: # <order>:<middleware-name>:<fully-qualified-package-name>
#
# External middleware example: # External middleware example:
# 80:log:github.com/miekg/coredns/middleware/log # 80:log:github.com/miekg/coredns/middleware/log
# Local middleware example: # Local middleware example:
# 80:log: # 80:log:log
10:root: 10:root:root
20:bind: 20:bind:bind
30:trace: 30:trace:trace
40:health: 40:health:health
50:pprof: 50:pprof:pprof
60:prometheus: 60:prometheus:metrics
70:errors: 70:errors:errors
80:log: 80:log:log
90:chaos: 90:chaos:chaos
100:cache: 100:cache:cache
110:rewrite: 110:rewrite:rewrite
120:loadbalance: 120:loadbalance:loadbalance
130:dnssec: 130:dnssec:dnssec
140:file: 140:file:file
150:auto: 150:auto:auto
160:secondary: 160:secondary:secondary
170:etcd: 170:etcd:etcd
180:kubernetes: 180:kubernetes:kubernetes
185:reverse: 185:reverse:reverse
190:proxy: 190:proxy:proxy
200:httpprox: 210:whoami:whoami
210:whoami: 220:erratic:erratic
220:erratic: