-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
caddyfile: Populate regexp matcher names by default #6145
Conversation
I implemented it for the expression matchers as well. It's kinda gnarly though:
|
Thanks for all this work, wow. I do have concerns that it feels quite complex (code logic) just to save 1 token (or possibly 2 tokens) in the config. I also wonder what if the matcher has multiple regexes? (I think that's possible, IIRC. Maybe not. Haven't looked lol) |
It's only possible if you use At that point, the user is expected to use a name to disambiguate them. |
edf283f
to
9b757ce
Compare
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.
Nice work -- thank you Francis for improving the Caddyfile!
This is something I've been mulling over for months, I was trying to think of the right solution to solve this, and I think I finally just realized "duh, just add a context map to the dispenser".
The idea is that often users might define a named matcher with a regexp like this:
We wrote
oldposts
a total of four times 😬 What if we instead we could omit having to name the regexp, when we've already named the named matcher? With this PR, now this works:Anyway, this is kinda complementary to #6113 but totally independent. With that one, this is possible, by not even using the matcher name at all:
Which is fine for simple cases where the regexp is used immediate after matching and there's no risk of another regexp matcher clobbering it.
Worth noting, because of how CEL matchers are compiled & provisioned at runtime, and not at Caddyfile-adapt time, this feature doesn't work for passing names into expression matchers right now. It might be possible to add the matcher name to the
expression
matcher's JSON as well, so that at runtime it can add it to the context when provisioning. Not sure if that's worth doing yet, but I might take a crack at it just for completion's sake.