diff options
author | Matthew Holt <mholt@users.noreply.github.com> | 2020-02-07 21:59:25 -0700 |
---|---|---|
committer | Matthew Holt <mholt@users.noreply.github.com> | 2020-02-07 21:59:25 -0700 |
commit | f7f6e371efcc6ddbbef56cd02c9e02fbcede033f (patch) | |
tree | 4da278ef960f1c488d7c579ba220e10fca2e49b0 | |
parent | b8cf4d589773e918606a20cf51776ca3cfc1233c (diff) |
tls: Slight adjustment to how DNS provider modules are loaded
We don't load the provider directly, because the lego provider types
aren't designed for JSON configuration and they are not implemented
as Caddy modules (there are some setup steps which a Provision call
would need to do, but they do not have Provision methods, they have
their own constructor functions that we have to wrap).
Instead of loading the challenge providers directly, the modules are
simple wrappers over the challenge providers, to facilitate the JSON
config structure and to provide a consistent experience. This also lets
us swap out the underlying challenge providers transparently if needed;
it acts as a layer of abstraction.
-rw-r--r-- | modules/caddytls/acmemanager.go | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/modules/caddytls/acmemanager.go b/modules/caddytls/acmemanager.go index 8e60183..df73545 100644 --- a/modules/caddytls/acmemanager.go +++ b/modules/caddytls/acmemanager.go @@ -111,7 +111,11 @@ func (m *ACMEManagerMaker) Provision(ctx caddy.Context) error { if err != nil { return fmt.Errorf("loading DNS provider module: %v", err) } - m.Challenges.DNS = val.(challenge.Provider) + prov, err := val.(DNSProviderMaker).NewDNSProvider() + if err != nil { + return fmt.Errorf("making DNS provider: %v", err) + } + m.Challenges.DNS = prov } // policy-specific storage implementation @@ -238,5 +242,11 @@ func onDemandAskRequest(ask string, name string) error { return nil } +// DNSProviderMaker is a type that can create a new DNS provider. +// Modules in the tls.dns namespace should implement this interface. +type DNSProviderMaker interface { + NewDNSProvider() (challenge.Provider, error) +} + // Interface guard var _ ManagerMaker = (*ACMEManagerMaker)(nil) |