pteich / caddy-tlsconsul

🔒 Consul K/V storage for Caddy Web Server / Certmagic TLS data
Apache License 2.0
96 stars 17 forks source link

Migrate to new Storage interface #3

Closed francislavoie closed 5 years ago

francislavoie commented 5 years ago

Just a few hours ago, @mholt merged his changed to pull caddytls out into its own repo called certmagic. Along with that comes a new Storage interface which can be used to plug into certmagic. Check it out here: https://github.com/mholt/certmagic/blob/master/storage.go

Note that it looks like the storage option was commented out along with those changes though https://github.com/mholt/caddy/blob/e0f1a02/caddytls/setup.go#L256, but that's probably just temporary.

mholt commented 5 years ago

Wow I totally didn't know people actually used this -- I starred this repo way back when I heard about it but thought it was just some tinkering. I guess I forgot about this!

I'm working on making storage plugins in Caddy first-class, actual plugins, that can be published to the Caddy website.

But there's gonna be a few more changes first. Like, they'll probably be called clustering plugins, rather than storage plugins, and they'll be plugged into the caddy package, not the caddytls package.

A clustering plugin must implement storage and locking (synchronization) for use in a cluster, but they're both very simple interfaces:

And it will be configured by environment variable, I think. Stay tuned.

mholt commented 5 years ago

Okay here's the deal: Caddy now supports what are called "cluster plugins" (or "clustering plugins") and you just have to implement the Storage interface (Locker was embedded into it).

Here is a new wiki page describing how to do it: https://github.com/mholt/caddy/wiki/Writing-a-Plugin:-Cluster-Support

And these are now first-class plugins you can publish to the Caddy website by creating an account and logging in, then clicking Register Plugin. Your cluster plugin should be recognized if it calls caddy.RegisterClusterPlugin according to the wiki instructions.

Have fun! Let me know if it doesn't work. 😅

pteich commented 5 years ago

I created this plugin it for myself and we use it heavily in production for quite a long time now. 😅 I'll have a look into the cluster plugin implementation @mholt mentioned and see what I can do with this. Thanks for pointing this out!

pteich commented 5 years ago

I did a more or less complete rewrite to implement the new certmagic.Storage interface. Thanks @mholt for the detailed information. :) If you want to have a look first, this is my PR: https://github.com/pteich/caddy-tlsconsul/pull/4