mirror of
https://github.com/coredns/coredns.git
synced 2025-10-29 17:24:20 -04:00
middleware/chaos: fix version (#669)
* middleware/chaos: fix version Move the version setting into a init function so it is done early. Then tweak the setup code for chaos a bit to correctly pick this version up. Add an integration test to pick this up in the toplevel test/ directory. Fixes #667 * Update tests
This commit is contained in:
committed by
John Belamaric
parent
7e6f5c77aa
commit
024f56682d
@@ -12,6 +12,7 @@ func init() {
|
||||
ServerType: "dns",
|
||||
Action: setup,
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
func setup(c *caddy.Controller) error {
|
||||
@@ -28,13 +29,16 @@ func setup(c *caddy.Controller) error {
|
||||
}
|
||||
|
||||
func chaosParse(c *caddy.Controller) (string, map[string]bool, error) {
|
||||
// Set here so we pick up AppName and AppVersion that get set in coremain's init().
|
||||
chaosVersion = caddy.AppName + "-" + caddy.AppVersion
|
||||
|
||||
version := ""
|
||||
authors := make(map[string]bool)
|
||||
|
||||
for c.Next() {
|
||||
args := c.RemainingArgs()
|
||||
if len(args) == 0 {
|
||||
return defaultVersion, nil, nil
|
||||
return chaosVersion, nil, nil
|
||||
}
|
||||
if len(args) == 1 {
|
||||
return args[0], nil, nil
|
||||
@@ -48,4 +52,4 @@ func chaosParse(c *caddy.Controller) (string, map[string]bool, error) {
|
||||
return version, authors, nil
|
||||
}
|
||||
|
||||
var defaultVersion = caddy.AppName + "-" + caddy.AppVersion
|
||||
var chaosVersion string
|
||||
|
||||
Reference in New Issue
Block a user