coredns/plugin/chaos/setup.go

67 lines
1.3 KiB
Go
Raw Normal View History

plugin/chaos: add default list of authors (#2737) * plugin/chaos: add default list of authors Add a owners_generate.go that generates a Owners variables for use in the chaos plugin. Add a default list of authors in the authors.bind CH zone. When doing a query this now returns: ~~~ sh % dig authors.bind TXT CH ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 5456 ;; flags: qr rd; QUERY: 1, ANSWER: 22, AUTHORITY: 0, ADDITIONAL: 1 ;; WARNING: recursion requested but not available ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ;; QUESTION SECTION: ;authors.bind. CH TXT ;; ANSWER SECTION: authors.bind. 0 CH TXT "bradbeam" authors.bind. 0 CH TXT "chrisohaver" authors.bind. 0 CH TXT "dilyevsky" authors.bind. 0 CH TXT "ekleiner" authors.bind. 0 CH TXT "fastest963" authors.bind. 0 CH TXT "fturib" authors.bind. 0 CH TXT "greenpau" authors.bind. 0 CH TXT "grobie" authors.bind. 0 CH TXT "inigohu" authors.bind. 0 CH TXT "isolus" authors.bind. 0 CH TXT "johnbelamaric" authors.bind. 0 CH TXT "miekg" authors.bind. 0 CH TXT "nchrisdk" authors.bind. 0 CH TXT "nitisht" authors.bind. 0 CH TXT "pmoroney" authors.bind. 0 CH TXT "rajansandeep" authors.bind. 0 CH TXT "rdrozhdzh" authors.bind. 0 CH TXT "rtreffer" authors.bind. 0 CH TXT "stp-ip" authors.bind. 0 CH TXT "superq" authors.bind. 0 CH TXT "varyoo" authors.bind. 0 CH TXT "yongtang" ~~~ This was hard to do previously as we didn't hardcode this in the source, but now with OWNERS files we can just generate this list. Privacy wise this isn't worse than being listed in OWNERS file in the first place. And it's a nice hat tip to the people making CoreDNS better. Signed-off-by: Miek Gieben <miek@miek.nl> * Sticklet bot comments Signed-off-by: Miek Gieben <miek@miek.nl>
2019-03-31 19:01:11 +01:00
//go:generate go run owners_generate.go
package chaos
import (
plugin/chaos: add default list of authors (#2737) * plugin/chaos: add default list of authors Add a owners_generate.go that generates a Owners variables for use in the chaos plugin. Add a default list of authors in the authors.bind CH zone. When doing a query this now returns: ~~~ sh % dig authors.bind TXT CH ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 5456 ;; flags: qr rd; QUERY: 1, ANSWER: 22, AUTHORITY: 0, ADDITIONAL: 1 ;; WARNING: recursion requested but not available ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ;; QUESTION SECTION: ;authors.bind. CH TXT ;; ANSWER SECTION: authors.bind. 0 CH TXT "bradbeam" authors.bind. 0 CH TXT "chrisohaver" authors.bind. 0 CH TXT "dilyevsky" authors.bind. 0 CH TXT "ekleiner" authors.bind. 0 CH TXT "fastest963" authors.bind. 0 CH TXT "fturib" authors.bind. 0 CH TXT "greenpau" authors.bind. 0 CH TXT "grobie" authors.bind. 0 CH TXT "inigohu" authors.bind. 0 CH TXT "isolus" authors.bind. 0 CH TXT "johnbelamaric" authors.bind. 0 CH TXT "miekg" authors.bind. 0 CH TXT "nchrisdk" authors.bind. 0 CH TXT "nitisht" authors.bind. 0 CH TXT "pmoroney" authors.bind. 0 CH TXT "rajansandeep" authors.bind. 0 CH TXT "rdrozhdzh" authors.bind. 0 CH TXT "rtreffer" authors.bind. 0 CH TXT "stp-ip" authors.bind. 0 CH TXT "superq" authors.bind. 0 CH TXT "varyoo" authors.bind. 0 CH TXT "yongtang" ~~~ This was hard to do previously as we didn't hardcode this in the source, but now with OWNERS files we can just generate this list. Privacy wise this isn't worse than being listed in OWNERS file in the first place. And it's a nice hat tip to the people making CoreDNS better. Signed-off-by: Miek Gieben <miek@miek.nl> * Sticklet bot comments Signed-off-by: Miek Gieben <miek@miek.nl>
2019-03-31 19:01:11 +01:00
"sort"
"github.com/coredns/caddy"
"github.com/coredns/coredns/core/dnsserver"
"github.com/coredns/coredns/plugin"
)
func init() { plugin.Register("chaos", setup) }
func setup(c *caddy.Controller) error {
plugin/chaos: add default list of authors (#2737) * plugin/chaos: add default list of authors Add a owners_generate.go that generates a Owners variables for use in the chaos plugin. Add a default list of authors in the authors.bind CH zone. When doing a query this now returns: ~~~ sh % dig authors.bind TXT CH ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 5456 ;; flags: qr rd; QUERY: 1, ANSWER: 22, AUTHORITY: 0, ADDITIONAL: 1 ;; WARNING: recursion requested but not available ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ;; QUESTION SECTION: ;authors.bind. CH TXT ;; ANSWER SECTION: authors.bind. 0 CH TXT "bradbeam" authors.bind. 0 CH TXT "chrisohaver" authors.bind. 0 CH TXT "dilyevsky" authors.bind. 0 CH TXT "ekleiner" authors.bind. 0 CH TXT "fastest963" authors.bind. 0 CH TXT "fturib" authors.bind. 0 CH TXT "greenpau" authors.bind. 0 CH TXT "grobie" authors.bind. 0 CH TXT "inigohu" authors.bind. 0 CH TXT "isolus" authors.bind. 0 CH TXT "johnbelamaric" authors.bind. 0 CH TXT "miekg" authors.bind. 0 CH TXT "nchrisdk" authors.bind. 0 CH TXT "nitisht" authors.bind. 0 CH TXT "pmoroney" authors.bind. 0 CH TXT "rajansandeep" authors.bind. 0 CH TXT "rdrozhdzh" authors.bind. 0 CH TXT "rtreffer" authors.bind. 0 CH TXT "stp-ip" authors.bind. 0 CH TXT "superq" authors.bind. 0 CH TXT "varyoo" authors.bind. 0 CH TXT "yongtang" ~~~ This was hard to do previously as we didn't hardcode this in the source, but now with OWNERS files we can just generate this list. Privacy wise this isn't worse than being listed in OWNERS file in the first place. And it's a nice hat tip to the people making CoreDNS better. Signed-off-by: Miek Gieben <miek@miek.nl> * Sticklet bot comments Signed-off-by: Miek Gieben <miek@miek.nl>
2019-03-31 19:01:11 +01:00
version, authors, err := parse(c)
if err != nil {
return plugin.Error("chaos", err)
}
dnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler {
return Chaos{Next: next, Version: version, Authors: authors}
})
return nil
}
plugin/chaos: add default list of authors (#2737) * plugin/chaos: add default list of authors Add a owners_generate.go that generates a Owners variables for use in the chaos plugin. Add a default list of authors in the authors.bind CH zone. When doing a query this now returns: ~~~ sh % dig authors.bind TXT CH ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 5456 ;; flags: qr rd; QUERY: 1, ANSWER: 22, AUTHORITY: 0, ADDITIONAL: 1 ;; WARNING: recursion requested but not available ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ;; QUESTION SECTION: ;authors.bind. CH TXT ;; ANSWER SECTION: authors.bind. 0 CH TXT "bradbeam" authors.bind. 0 CH TXT "chrisohaver" authors.bind. 0 CH TXT "dilyevsky" authors.bind. 0 CH TXT "ekleiner" authors.bind. 0 CH TXT "fastest963" authors.bind. 0 CH TXT "fturib" authors.bind. 0 CH TXT "greenpau" authors.bind. 0 CH TXT "grobie" authors.bind. 0 CH TXT "inigohu" authors.bind. 0 CH TXT "isolus" authors.bind. 0 CH TXT "johnbelamaric" authors.bind. 0 CH TXT "miekg" authors.bind. 0 CH TXT "nchrisdk" authors.bind. 0 CH TXT "nitisht" authors.bind. 0 CH TXT "pmoroney" authors.bind. 0 CH TXT "rajansandeep" authors.bind. 0 CH TXT "rdrozhdzh" authors.bind. 0 CH TXT "rtreffer" authors.bind. 0 CH TXT "stp-ip" authors.bind. 0 CH TXT "superq" authors.bind. 0 CH TXT "varyoo" authors.bind. 0 CH TXT "yongtang" ~~~ This was hard to do previously as we didn't hardcode this in the source, but now with OWNERS files we can just generate this list. Privacy wise this isn't worse than being listed in OWNERS file in the first place. And it's a nice hat tip to the people making CoreDNS better. Signed-off-by: Miek Gieben <miek@miek.nl> * Sticklet bot comments Signed-off-by: Miek Gieben <miek@miek.nl>
2019-03-31 19:01:11 +01:00
func parse(c *caddy.Controller) (string, []string, error) {
// Set here so we pick up AppName and AppVersion that get set in coremain's init().
chaosVersion = caddy.AppName + "-" + caddy.AppVersion
version := ""
2022-07-10 20:06:33 +02:00
if c.Next() {
args := c.RemainingArgs()
if len(args) == 0 {
plugin/chaos: add default list of authors (#2737) * plugin/chaos: add default list of authors Add a owners_generate.go that generates a Owners variables for use in the chaos plugin. Add a default list of authors in the authors.bind CH zone. When doing a query this now returns: ~~~ sh % dig authors.bind TXT CH ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 5456 ;; flags: qr rd; QUERY: 1, ANSWER: 22, AUTHORITY: 0, ADDITIONAL: 1 ;; WARNING: recursion requested but not available ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ;; QUESTION SECTION: ;authors.bind. CH TXT ;; ANSWER SECTION: authors.bind. 0 CH TXT "bradbeam" authors.bind. 0 CH TXT "chrisohaver" authors.bind. 0 CH TXT "dilyevsky" authors.bind. 0 CH TXT "ekleiner" authors.bind. 0 CH TXT "fastest963" authors.bind. 0 CH TXT "fturib" authors.bind. 0 CH TXT "greenpau" authors.bind. 0 CH TXT "grobie" authors.bind. 0 CH TXT "inigohu" authors.bind. 0 CH TXT "isolus" authors.bind. 0 CH TXT "johnbelamaric" authors.bind. 0 CH TXT "miekg" authors.bind. 0 CH TXT "nchrisdk" authors.bind. 0 CH TXT "nitisht" authors.bind. 0 CH TXT "pmoroney" authors.bind. 0 CH TXT "rajansandeep" authors.bind. 0 CH TXT "rdrozhdzh" authors.bind. 0 CH TXT "rtreffer" authors.bind. 0 CH TXT "stp-ip" authors.bind. 0 CH TXT "superq" authors.bind. 0 CH TXT "varyoo" authors.bind. 0 CH TXT "yongtang" ~~~ This was hard to do previously as we didn't hardcode this in the source, but now with OWNERS files we can just generate this list. Privacy wise this isn't worse than being listed in OWNERS file in the first place. And it's a nice hat tip to the people making CoreDNS better. Signed-off-by: Miek Gieben <miek@miek.nl> * Sticklet bot comments Signed-off-by: Miek Gieben <miek@miek.nl>
2019-03-31 19:01:11 +01:00
return trim(chaosVersion), Owners, nil
}
if len(args) == 1 {
plugin/chaos: add default list of authors (#2737) * plugin/chaos: add default list of authors Add a owners_generate.go that generates a Owners variables for use in the chaos plugin. Add a default list of authors in the authors.bind CH zone. When doing a query this now returns: ~~~ sh % dig authors.bind TXT CH ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 5456 ;; flags: qr rd; QUERY: 1, ANSWER: 22, AUTHORITY: 0, ADDITIONAL: 1 ;; WARNING: recursion requested but not available ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ;; QUESTION SECTION: ;authors.bind. CH TXT ;; ANSWER SECTION: authors.bind. 0 CH TXT "bradbeam" authors.bind. 0 CH TXT "chrisohaver" authors.bind. 0 CH TXT "dilyevsky" authors.bind. 0 CH TXT "ekleiner" authors.bind. 0 CH TXT "fastest963" authors.bind. 0 CH TXT "fturib" authors.bind. 0 CH TXT "greenpau" authors.bind. 0 CH TXT "grobie" authors.bind. 0 CH TXT "inigohu" authors.bind. 0 CH TXT "isolus" authors.bind. 0 CH TXT "johnbelamaric" authors.bind. 0 CH TXT "miekg" authors.bind. 0 CH TXT "nchrisdk" authors.bind. 0 CH TXT "nitisht" authors.bind. 0 CH TXT "pmoroney" authors.bind. 0 CH TXT "rajansandeep" authors.bind. 0 CH TXT "rdrozhdzh" authors.bind. 0 CH TXT "rtreffer" authors.bind. 0 CH TXT "stp-ip" authors.bind. 0 CH TXT "superq" authors.bind. 0 CH TXT "varyoo" authors.bind. 0 CH TXT "yongtang" ~~~ This was hard to do previously as we didn't hardcode this in the source, but now with OWNERS files we can just generate this list. Privacy wise this isn't worse than being listed in OWNERS file in the first place. And it's a nice hat tip to the people making CoreDNS better. Signed-off-by: Miek Gieben <miek@miek.nl> * Sticklet bot comments Signed-off-by: Miek Gieben <miek@miek.nl>
2019-03-31 19:01:11 +01:00
return trim(args[0]), Owners, nil
}
plugin/chaos: add default list of authors (#2737) * plugin/chaos: add default list of authors Add a owners_generate.go that generates a Owners variables for use in the chaos plugin. Add a default list of authors in the authors.bind CH zone. When doing a query this now returns: ~~~ sh % dig authors.bind TXT CH ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 5456 ;; flags: qr rd; QUERY: 1, ANSWER: 22, AUTHORITY: 0, ADDITIONAL: 1 ;; WARNING: recursion requested but not available ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ;; QUESTION SECTION: ;authors.bind. CH TXT ;; ANSWER SECTION: authors.bind. 0 CH TXT "bradbeam" authors.bind. 0 CH TXT "chrisohaver" authors.bind. 0 CH TXT "dilyevsky" authors.bind. 0 CH TXT "ekleiner" authors.bind. 0 CH TXT "fastest963" authors.bind. 0 CH TXT "fturib" authors.bind. 0 CH TXT "greenpau" authors.bind. 0 CH TXT "grobie" authors.bind. 0 CH TXT "inigohu" authors.bind. 0 CH TXT "isolus" authors.bind. 0 CH TXT "johnbelamaric" authors.bind. 0 CH TXT "miekg" authors.bind. 0 CH TXT "nchrisdk" authors.bind. 0 CH TXT "nitisht" authors.bind. 0 CH TXT "pmoroney" authors.bind. 0 CH TXT "rajansandeep" authors.bind. 0 CH TXT "rdrozhdzh" authors.bind. 0 CH TXT "rtreffer" authors.bind. 0 CH TXT "stp-ip" authors.bind. 0 CH TXT "superq" authors.bind. 0 CH TXT "varyoo" authors.bind. 0 CH TXT "yongtang" ~~~ This was hard to do previously as we didn't hardcode this in the source, but now with OWNERS files we can just generate this list. Privacy wise this isn't worse than being listed in OWNERS file in the first place. And it's a nice hat tip to the people making CoreDNS better. Signed-off-by: Miek Gieben <miek@miek.nl> * Sticklet bot comments Signed-off-by: Miek Gieben <miek@miek.nl>
2019-03-31 19:01:11 +01:00
version = args[0]
plugin/chaos: add default list of authors (#2737) * plugin/chaos: add default list of authors Add a owners_generate.go that generates a Owners variables for use in the chaos plugin. Add a default list of authors in the authors.bind CH zone. When doing a query this now returns: ~~~ sh % dig authors.bind TXT CH ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 5456 ;; flags: qr rd; QUERY: 1, ANSWER: 22, AUTHORITY: 0, ADDITIONAL: 1 ;; WARNING: recursion requested but not available ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ;; QUESTION SECTION: ;authors.bind. CH TXT ;; ANSWER SECTION: authors.bind. 0 CH TXT "bradbeam" authors.bind. 0 CH TXT "chrisohaver" authors.bind. 0 CH TXT "dilyevsky" authors.bind. 0 CH TXT "ekleiner" authors.bind. 0 CH TXT "fastest963" authors.bind. 0 CH TXT "fturib" authors.bind. 0 CH TXT "greenpau" authors.bind. 0 CH TXT "grobie" authors.bind. 0 CH TXT "inigohu" authors.bind. 0 CH TXT "isolus" authors.bind. 0 CH TXT "johnbelamaric" authors.bind. 0 CH TXT "miekg" authors.bind. 0 CH TXT "nchrisdk" authors.bind. 0 CH TXT "nitisht" authors.bind. 0 CH TXT "pmoroney" authors.bind. 0 CH TXT "rajansandeep" authors.bind. 0 CH TXT "rdrozhdzh" authors.bind. 0 CH TXT "rtreffer" authors.bind. 0 CH TXT "stp-ip" authors.bind. 0 CH TXT "superq" authors.bind. 0 CH TXT "varyoo" authors.bind. 0 CH TXT "yongtang" ~~~ This was hard to do previously as we didn't hardcode this in the source, but now with OWNERS files we can just generate this list. Privacy wise this isn't worse than being listed in OWNERS file in the first place. And it's a nice hat tip to the people making CoreDNS better. Signed-off-by: Miek Gieben <miek@miek.nl> * Sticklet bot comments Signed-off-by: Miek Gieben <miek@miek.nl>
2019-03-31 19:01:11 +01:00
authors := make(map[string]struct{})
for _, a := range args[1:] {
authors[a] = struct{}{}
}
plugin/chaos: add default list of authors (#2737) * plugin/chaos: add default list of authors Add a owners_generate.go that generates a Owners variables for use in the chaos plugin. Add a default list of authors in the authors.bind CH zone. When doing a query this now returns: ~~~ sh % dig authors.bind TXT CH ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 5456 ;; flags: qr rd; QUERY: 1, ANSWER: 22, AUTHORITY: 0, ADDITIONAL: 1 ;; WARNING: recursion requested but not available ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ;; QUESTION SECTION: ;authors.bind. CH TXT ;; ANSWER SECTION: authors.bind. 0 CH TXT "bradbeam" authors.bind. 0 CH TXT "chrisohaver" authors.bind. 0 CH TXT "dilyevsky" authors.bind. 0 CH TXT "ekleiner" authors.bind. 0 CH TXT "fastest963" authors.bind. 0 CH TXT "fturib" authors.bind. 0 CH TXT "greenpau" authors.bind. 0 CH TXT "grobie" authors.bind. 0 CH TXT "inigohu" authors.bind. 0 CH TXT "isolus" authors.bind. 0 CH TXT "johnbelamaric" authors.bind. 0 CH TXT "miekg" authors.bind. 0 CH TXT "nchrisdk" authors.bind. 0 CH TXT "nitisht" authors.bind. 0 CH TXT "pmoroney" authors.bind. 0 CH TXT "rajansandeep" authors.bind. 0 CH TXT "rdrozhdzh" authors.bind. 0 CH TXT "rtreffer" authors.bind. 0 CH TXT "stp-ip" authors.bind. 0 CH TXT "superq" authors.bind. 0 CH TXT "varyoo" authors.bind. 0 CH TXT "yongtang" ~~~ This was hard to do previously as we didn't hardcode this in the source, but now with OWNERS files we can just generate this list. Privacy wise this isn't worse than being listed in OWNERS file in the first place. And it's a nice hat tip to the people making CoreDNS better. Signed-off-by: Miek Gieben <miek@miek.nl> * Sticklet bot comments Signed-off-by: Miek Gieben <miek@miek.nl>
2019-03-31 19:01:11 +01:00
list := []string{}
for k := range authors {
k = trim(k) // limit size to 255 chars
list = append(list, k)
}
sort.Strings(list)
return version, list, nil
}
return version, Owners, nil
}
func trim(s string) string {
if len(s) < 256 {
return s
}
plugin/chaos: add default list of authors (#2737) * plugin/chaos: add default list of authors Add a owners_generate.go that generates a Owners variables for use in the chaos plugin. Add a default list of authors in the authors.bind CH zone. When doing a query this now returns: ~~~ sh % dig authors.bind TXT CH ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 5456 ;; flags: qr rd; QUERY: 1, ANSWER: 22, AUTHORITY: 0, ADDITIONAL: 1 ;; WARNING: recursion requested but not available ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ;; QUESTION SECTION: ;authors.bind. CH TXT ;; ANSWER SECTION: authors.bind. 0 CH TXT "bradbeam" authors.bind. 0 CH TXT "chrisohaver" authors.bind. 0 CH TXT "dilyevsky" authors.bind. 0 CH TXT "ekleiner" authors.bind. 0 CH TXT "fastest963" authors.bind. 0 CH TXT "fturib" authors.bind. 0 CH TXT "greenpau" authors.bind. 0 CH TXT "grobie" authors.bind. 0 CH TXT "inigohu" authors.bind. 0 CH TXT "isolus" authors.bind. 0 CH TXT "johnbelamaric" authors.bind. 0 CH TXT "miekg" authors.bind. 0 CH TXT "nchrisdk" authors.bind. 0 CH TXT "nitisht" authors.bind. 0 CH TXT "pmoroney" authors.bind. 0 CH TXT "rajansandeep" authors.bind. 0 CH TXT "rdrozhdzh" authors.bind. 0 CH TXT "rtreffer" authors.bind. 0 CH TXT "stp-ip" authors.bind. 0 CH TXT "superq" authors.bind. 0 CH TXT "varyoo" authors.bind. 0 CH TXT "yongtang" ~~~ This was hard to do previously as we didn't hardcode this in the source, but now with OWNERS files we can just generate this list. Privacy wise this isn't worse than being listed in OWNERS file in the first place. And it's a nice hat tip to the people making CoreDNS better. Signed-off-by: Miek Gieben <miek@miek.nl> * Sticklet bot comments Signed-off-by: Miek Gieben <miek@miek.nl>
2019-03-31 19:01:11 +01:00
return s[:255]
}
var chaosVersion string