fixup logger usage (#33)

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2020-09-05 02:43:16 +03:00
committed by GitHub
parent c576749b57
commit e7d418183b
8 changed files with 53 additions and 41 deletions

View File

@@ -3,13 +3,13 @@ package certmagic
import (
"crypto/tls"
"fmt"
"math/rand"
"net"
"time"
"github.com/caddyserver/certmagic"
"github.com/unistack-org/micro/v3/api/server/acme"
"github.com/unistack-org/micro/v3/logger"
)
type certmagicProvider struct {
@@ -48,6 +48,15 @@ func (c *certmagicProvider) TLSConfig(hosts ...string) (*tls.Config, error) {
return certmagic.TLS(hosts)
}
func (p *certmagicProvider) Init(opts ...acme.Option) error {
if p.opts.Cache != nil {
if _, ok := p.opts.Cache.(certmagic.Storage); !ok {
return fmt.Errorf("ACME: cache provided doesn't implement certmagic's Storage interface")
}
}
return nil
}
// NewProvider returns a certmagic provider
func NewProvider(options ...acme.Option) acme.Provider {
opts := acme.DefaultOptions()
@@ -56,12 +65,6 @@ func NewProvider(options ...acme.Option) acme.Provider {
o(&opts)
}
if opts.Cache != nil {
if _, ok := opts.Cache.(certmagic.Storage); !ok {
logger.Fatal("ACME: cache provided doesn't implement certmagic's Storage interface")
}
}
return &certmagicProvider{
opts: opts,
}