Closed Gurpartap closed 3 years ago
@Gurpartap Where does your code snippet come from or in other words how do you use Caddy and in specific this plugin? Maybe it is just another use-case I not really cover by now.
@Gurpartap After issuing storageconsul.New()
it has to be provisioned. Caddy does this be calling storageInstanceVariable.Provision(ctx caddy.Context)
The reason is that it needs the caddy.Context
that carries a logger instance. This is all done automatically if you just include this plugin and activate it in your Caddy config. Normally there is no need to code anything.
Thanks. I'll try that today, and let you know.
I'm not using Caddy. Only certmagic with plain http.Server{}.
Ok, I see. You can also use an approach like this:
cs := storageconsul.New()
cs.Prefix = "your-consul-kv-prefix"
cs.AESKey = []byte("12345678901234567890123456789012")
client, err := api.NewClient(api.DefaultConfig())
if err != nil {
panic(err)
}
cs.ConsulClient = client
certmagic.Default.Storage = cs
Thank you @pteich. That worked perfectly. Feel free to close the thread.
Might be worthwhile making func (cs *ConsulStorage) createConsulClient() error {}
public.
Great @Gurpartap - I was not aware of that use-case by now. I consider your idea or maybe add a NewWithConsulClient()
func that calls createConsulClient
internally as this feels more natural to me.
Getting this panic error after upgrading certmagic, dns provider, storage, etc. modules. Not sure if it matters, but I switched from dnsimple to cloudflare dns provider as well.