A plugin’s package should register its own flags, so if the HTTP server is plugged in, its flags will be registered. Namespacing them isn’t a bad idea but I think we should wait until the next major release (0.10 probably?) to do that, if we decide to do that.
@miekg I’m gonna revisit this now, since I can’t build CoreDNS with the HTTP server together, because they both register a port flag.
Would it be too much to ask if CoreDNS’ flag was called dnsport instead? Or dns.port? Perhaps your own main package could still register it as port for convenience but the dnsserver package registering port overlaps with the httpserver (I could perhaps change it except that it would break a lot more users - maybe on the 0.10 branch I can change all the flags… hmmm)…
Told you so
I think we should namespace, httpport, dnsport sounds good to me. dnsquiet, httpquiet irks me a bit, but there should be rules, we expect each other to rename flags whenever there is (a future) conflict.
Namespace with a dot in between? Prometheus does this too, not sure if there is some kind official support for this kind of namespacing
Oh, so actually, the -quiet flag is defined by Caddy’s run.go so it’s not in a server type… and that’s fine, I think. Your dnsserver package can just use caddy.Quiet (or move the flag registration into your main instead).
I think I like the idea of namespacing with a dot. http.port and dns.port… although that’s kind of too bad from a UX perspective since -type=http or -type=dns should make it obvious which server type we’re using, and thus which namespace. But I guess we can’t tell the Go flags package how that works.
Hmm, I should be able to move Quiet back to run.go, was more of a convenience.
Interesting remark about go’s flags. Couldn’t we have separate flagSets per server type for these kind of overlapping flags or would they then still clash.
I think perhaps the “simplest” way to solve this is to just namespace the flags. Otherwise we’d have to write our own flag package or something…
So if I change the http server’s flags to http.* for 0.10, would you change the flags in your DNS server to dns.*?
Yes, I think so! Any flags registered as a side-effect of importing the dnsserver package (and, I guess, any packages it imports) should be scoped to dns.*. Thanks!