Caddy v2 version? #4
Comments
Next week, probably. |
@codeagencybe kindly check version v0.2.0-beta.1 |
Thank you @gamalan
|
Ah, yeah, if you want to use it with the Caddyfile, the same module that implements StorageConverter needs to implement the caddyfile.Unmarshaler interface too. It's pretty simple, a great example is in the default FileStorage converter: https://github.com/caddyserver/caddy/blob/ec456811bb6d61ce32dbe6e4b7580d383f8a4adf/modules/filestorage/filestorage.go#L46 |
ah, i thought it was not necessary. @mholt does it need to implement even if it doesn't take any parameter from caddyfile? or how does unmarshaler works, especially for storage part? |
@gamalan It's not strictly required, but it is if you want people to be able to use your module from the Caddyfile, i.e. to have a Caddyfile interface. All it has to do is iterate the tokens and unpack them into your struct for config. For example, your JSON interface is currently something like: {
"module": "redis",
"Options": {
"Host": "localhost",
"Port": "1234"
}
} (see my PS below for suggestions to improve this) Then if people want to use the Caddyfile to configure it instead, they might do:
So you'd simply iterate the next token and assign their value to the Host and Port fields on your struct. That's all! See how the example I linked to above does it, it's just a few lines of code: PS. You might consider simplifying the JSON interface if you can, i.e. Host and Port could be combined and you can then use net.SplitHostPort if you need them separate (or caddy.ParseNetworkAddress, if possible!). And do you really need a separate struct for Options? Also, you should put caddy-tlsredis/storageredis.go Lines 28 to 33 in 146ff95
|
Well, it's because caddy v1 doesn't have standard storage directive yet, afaik. Assuming if i don't use the caddyfile yet, i can just add the function and skip it right?
|
@gamalan To clarify, you don't need to add that method at all -- might as well not add it if it will be empty. The point of adding it is to let people configure your module from the Caddyfile. If you add it but leave it empty, they will think they've configured it (they won't get an error) but in reality it will have all empty values. You're definitely not obligated to implement it yourself; anyone could spend a few minutes and submit a pull request, I suppose. When you are ready, let me help you finish the transition to v2! 👍 I can give you some pointers and review code, no problem. |
but @mholt your previous comment
means, it is necessary to be added, for now(?) |
Necessary for what, precisely?
|
ah I see, so this error won't happen if running caddy v2 without
|
Ahh... you are not aware yet how Caddy 2 config works. Caddy 2's native config is JSON. The Caddyfile is simply a wrapper ("config adapter") over it that converts the Caddyfile into JSON: https://caddyserver.com/docs/config-adapters Making plugins work with the Caddyfile is totally optional, since Caddy 2 does not use it for config. You only have to run To summarize:
|
I see, I've read but not in full, and want to make sure. Let me update it then. |
Thanks for building and maintaining this plugin! I think it'll be useful to a lot of people as v2 gains more steam. 😃 |
@mholt based on my understanding of how parsing caddyfile works, i could use something like this to looping the Caddyfile directive for example
just making sure |
Something like that, yep -- I think some improvements could be made to the API/structure here (again, something like combining the host and port, and making password optional so that it can be specified via env variables or something) -- but that's the right idea. Instead of just |
Yep, because the Redis client actually take host:port as a single address input. In the previous version, all parameter have default value, and can be set through env variable, so I will keep it like that while supporting Caddyfile format. |
Just a little feedback:
I used the Docker builder image to install the module with the RC3 release. The Caddy TLS Redis storage works just fine. I got new certificates generated for my domains and they are stored in Redis. So far, after a couple of days, I do not have noticed any issues or errors on the served sites. Thanks to @gamalan for making this module possible with v2 and to @mholt for giving the author some helping hints. I see that this pull request caddyserver/certmagic#66 will introduce some breaking changes in certmagic. I will keep an eye close, but I still have my certs in the local file storage in case I need to revert. Thank you once again! |
Awesome! Great report, thanks for the update. (That breaking change is easy to accommodate, I'll personally submit PRs to all repos I know it will affect, so you won't have much work to do!) |
Already update the implementation for v0.2.0-beta.2 |
Thank you @gamalan I updated my custom Caddy image with the v0.2.0-beta.2 release. All good for me:
|
Thanks for confirming @frenchvandal |
Hello
Is there any Caddy v2 version yet or in progress? Any ETA?
Thanks!
The text was updated successfully, but these errors were encountered: