-
-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Runtime placeholders #224
Runtime placeholders #224
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for contributing this. I haven't scrutinized each line but the approach looks good. If we're ready to merge it I will go ahead and do so 👍
repl := caddy.NewReplacer() | ||
for _, addrOrCIDR := range m.Ranges { | ||
addrOrCIDR = repl.ReplaceAll(addrOrCIDR, "") | ||
prefix, err := caddyhttp.CIDRExpressionToPrefix(addrOrCIDR) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this function should move to caddy
instead of caddyhttp
(since it can be used for more than just HTTP).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed the PR back at the caddy repo but I still wonder about this. What's the right package for this, do we think?
Looks like a rebase is needed after the lint fixes |
Seems like the build-test-check doesn't respect go.mod: it's trying to build caddy-l4 with caddy@v2.8.5 (unreleased yet, meaning the latest commit I believe) instead of caddy@v2.8.4. Or is it my fault somewhere? Shall we fix it here? |
Huh, that's strange. Weren't the tests succeeding at first? |
The tests had been successful before you merged caddyserver/caddy@59cbb2c moving PrivateRangesCIDR() from caddyhttp to internal. And the builds are made with |
Ohh. Yes, you're right. Sorry I see now that you linked to the cause. I think that's intentional because we want to be sure that this module is compatible with up-and-coming releases of Caddy. |
Then I believe we should wait until Caddy v2.8.5 is released, then I will update go.mod and this PR as well. |
Oops, it's my fault for not realizing it's used here and breaking it by suggesting moving the func 😶
I doubt this will solve anything. Should we duplicate the func or move it somewhere, as Matt suggested? |
As of now caddy-l4 builds in an IDE with go.mod requiring caddy v.2.8.4, but won't build here with If we release caddy v2.8.5 and adjust go.mod, caddy-l4 will build both in an IDE and here on github. On the other hand, if we adjust this PR now, there will be no failures on github, but caddy-l4 won't build in an IDE. Alternatively, we could adjust the build-test-check to respect go.mod, but @mholt mentioned that Finally, I don't think it's a good idea to duplicate the code. |
Adjust it how? There's no way to edit go.mod that'd fix it. If you change go.mod here to Caddy v2.8.5, it'll be the same issue as with I made a mistake suggesting moving the function to an internal package, which screwed up this PR. I can move it back to |
@mohammed90 I mean I can adjust this PR in 2 ways: 1) update go.mod to require Caddy v2.8.5; 2) update the code to call internal.PrivateRangesCIDR() instead of caddyhttp.PrivateRangesCIDR(). This way the build-test-check will pass, and the code will build in an IDE as well. I do think it was a good idea of yours to move the function. I didn’t know the build-test-check didn’t respect go.mod, and it was intentional. |
Code in |
Oops, now I understand your point. Is there any proper importable place in Caddy mainline where we could move the function other than back to caddyhttp? If no, then I agree, we can use caddyhttp as an easy fix. |
Given the burden of changing versions caused if put anywhere other than |
Tests are passing now! 🎉 But I am still wondering on the package home for that CIDR prefix function. It's not specific to HTTP, so I wonder if it should go in the |
If we move that CIDR prefix function to the |
True... well... I guess it's not a big deal, unless the |
Following our discussion in slack, these changes relax Caddyfile parsing and ensure runtime placeholders support across most handler and matcher options. Besides, I've updated README to document how runtime placeholders are treated in the code.
Examples of syntax which will work with these changes: