diff options
author | 2017-02-19 20:34:29 +0000 | |
---|---|---|
committer | 2017-02-19 20:34:29 +0000 | |
commit | ea38b642b82b0c10da6ace8709335c33f2fe020b (patch) | |
tree | 40eb1c4dbca985b0b4decf5be88c7ab3c1f6e28f /directives_generate.go | |
parent | bcd9c8b0fb83c4da4d84a2bafb1d1f8275b49b49 (diff) | |
download | coredns-ea38b642b82b0c10da6ace8709335c33f2fe020b.tar.gz coredns-ea38b642b82b0c10da6ace8709335c33f2fe020b.tar.zst coredns-ea38b642b82b0c10da6ace8709335c33f2fe020b.zip |
All middleware equal (#535)
* all-middleware-equal
* Revert "all-middleware-equal"
This reverts commit ee77b2a9816b1953a19fefb863875399aacd0c2a.
* 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
Diffstat (limited to 'directives_generate.go')
-rw-r--r-- | directives_generate.go | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/directives_generate.go b/directives_generate.go index ccee3a0f3..62e69e165 100644 --- a/directives_generate.go +++ b/directives_generate.go @@ -25,22 +25,23 @@ func main() { scanner := bufio.NewScanner(file) for scanner.Scan() { line := scanner.Text() - if !strings.HasPrefix(line, `//`) && !strings.HasPrefix(line, "#") { - items := strings.Split(line, ":") - if len(items) == 3 { - if priority, err := strconv.Atoi(items[0]); err == nil { - md[priority] = items[1] - } - - if items[2] != "" { - if strings.Contains(items[2], "/") { - mi[items[1]] = items[2] - } else { - mi[items[1]] = middlewarePath + items[2] - } - } - - } + if strings.HasPrefix(line, "#") { + continue + } + + items := strings.Split(line, ":") + if len(items) != 3 { + // ignore + continue + } + priority, err := strconv.Atoi(items[0]) + fatalIfErr(err) + + md[priority] = items[1] + mi[items[1]] = middlewarePath + items[2] // Default, unless overriden by 3rd arg + + if strings.Contains(items[2], "/") { // External package has been given + mi[items[1]] = items[2] } } |