-
-
Notifications
You must be signed in to change notification settings - Fork 979
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move DNS providers into a separate package #112
Conversation
Are you going to make some changes to this as #111 progresses? I like the idea of a registry but does that mean we have a registry for every challenge? |
Sure, I'll update this if it seems like it's on the right track. Would you like me to push each provider into a separate package as part of this PR? I'm not sure if we'll need a registry for every challenge. For DNS specifically, I expect DNS providers to continue multiplying more rapidly than other types of providers, and I think DNS providers should ultimately satisfy an interface more specialized than |
bf762c5
to
9f9c00a
Compare
9f9c00a
to
03be013
Compare
Yes I feel like moving each provider into its own package is the way to go. How would you specialize the interface for DNS providers while still being able to use them with the current structure though? |
I was leaning towards putting
Providers would need to import You mentioned in another issue that you'd like every challenge type to be solvable with just The key is that Then I had a second thought: we could make a lightweight DNS-01 provider and ship it inside |
This seems not intuitive to me. If I'd import
This is exactly how the manual provider works. The DNS propagation check is done in the challenge code and was even moved out into the |
Closing this as #144 is now merged. |
This changeset moves the DNS challenge providers into a new
dns_provider
package.This package a sibling of
acme
. I felt this was appropriate given the low amount of coupling betweenacme
anddns_provider
, and that this coupling can be reduced further. (The DNS providers don't need to know anything ACME-specific – they only need to be able to create and destroy TXT records with short TTLs – but that's a topic for a later changeset.)All the providers are together in the
dns_provider
package to keep this changeset minimal. Similarly, all the providers are initialized the way they were before – usually by passing in empty strings – even though there are clear opportunities for cleanup.The
lego
CLI interacts with this package viadns_provider.Registry
. This registry provides a list of entries describing the available DNS challenge providers in exactly the way thatlego help
describes them, andlego help
output is constructed based on the contents of this registry. Once the CLI decides it wants a specific entry, the CLI callsNewChallengeProvider()
to yield anacme.ChallengeProvider
.Individual providers register themselves like:
This pattern permits both additional refactoring into separate packages and conditional compilation (#111). Go guarantees that
init()
gets called after initializing imports and beforemain()
, so there's no fuss for either of those changes.