map bool -> map struct{} (#2386)

This clear out the remaining map[x]bool usage and moves the bool to an
empty struct.

Two note worthy other changes:

* EnableChaos in the server is now also exported to make it show up in
  the documentation.
* The auto plugin is left as is, because there the boolean is
  explicitaly set to false to signal 'to-be-deleted' and the key is left
  as-is.

Signed-off-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
Miek Gieben
2018-12-10 10:17:15 +00:00
committed by Yong Tang
parent c788649a00
commit 9abbf4a4a0
9 changed files with 64 additions and 63 deletions

View File

@@ -40,13 +40,13 @@ func logParse(c *caddy.Controller) ([]Rule, error) {
rules = append(rules, Rule{
NameScope: ".",
Format: DefaultLogFormat,
Class: make(map[response.Class]bool),
Class: make(map[response.Class]struct{}),
})
} else if len(args) == 1 {
rules = append(rules, Rule{
NameScope: dns.Fqdn(args[0]),
Format: DefaultLogFormat,
Class: make(map[response.Class]bool),
Class: make(map[response.Class]struct{}),
})
} else {
// Name scope, and maybe a format specified
@@ -64,7 +64,7 @@ func logParse(c *caddy.Controller) ([]Rule, error) {
rules = append(rules, Rule{
NameScope: dns.Fqdn(args[0]),
Format: format,
Class: make(map[response.Class]bool),
Class: make(map[response.Class]struct{}),
})
}
@@ -82,14 +82,14 @@ func logParse(c *caddy.Controller) ([]Rule, error) {
if err != nil {
return nil, err
}
rules[len(rules)-1].Class[cls] = true
rules[len(rules)-1].Class[cls] = struct{}{}
}
default:
return nil, c.ArgErr()
}
}
if len(rules[len(rules)-1].Class) == 0 {
rules[len(rules)-1].Class[response.All] = true
rules[len(rules)-1].Class[response.All] = struct{}{}
}
}