Sharing or disabling flags

As a server type plugin, is it possible to negate some flags? (Can flags be removed in Go?).

./caddy -type dns -h, looks kinda strange from a DNS viewpoint, with things like -quic and -http2.

Adding flags is not a problem of course.

Maybe some flag grouping per server plugin? -www.quic, -dns.bla?

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.

Are you seeing a conflict with the DNS server?

Yes, this can wait. Just wondering about future issues that might crop up, this is likely to be one of them.

Okay. Yeah, this is good to think about. We’ll revisit this before 0.10 I hope. Thanks!

@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)…

Edit: Oh, and the -quiet flag too… :innocent:

Told you so :slight_smile:
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. :stuck_out_tongue:

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.

https://github.com/miekg/coredns/pull/299 to move the -quiet flag out of register.go. That should solve 1 problem.

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.*? :blush:

yes, no problem.

We’re only talking about port right now, no?

https://github.com/miekg/coredns/pull/300 filed

1 Like

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!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.