-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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: Implement variadics for import args placeholders #5249
Conversation
Oooh, fun. Can you show an example Caddyfile with this? |
Very cool, thanks for working on this! We might need a test case for this, or at least an example that we know works. There's a number of test failures, currently. |
Hmm. I'm not sure how I feel about the |
Just |
Hmm, maybe. I think if we want to use the |
Personally, I'm ok with the |
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.
Is it possible to add a name for each test case like the below example given?
{
name: "Test duplicate import",
input: `(t1) {
abort {args.:}
}
:8080 {
import t1
import t1 true
}`,
errorText: "Caddyfile:6(import t1):2",
},
@rudSarkar That sounds like a good/useful idea. Could be done either in this PR or a later commit. |
@mholt I think It will be better to add this on later commit. |
imported snippets reflect actual lines in file
add tests for parsing
- Moved the import args handling to a separate file - Using {args[0:1]} syntax now - Deprecate {args.*} syntax - Use a replacer map for better control over the parsing - Add plenty of warnings when invalid placeholders are detected - Renaming variables, cleanup comments for readability - More tests to cover edgecases I could think of - Minor cleanup to snippet tracking in tokens, drop a redundant boolean field in tokens
38ee1df
to
c028b35
Compare
I worked on cleaning this up -- see recent commit for details. |
I think this is looking good! I might wait for #5275 though, so as to not introduce another conflict. Thanks for working on this both of you 😊 |
I don't think they'll conflict. This only affects the Caddyfile and that PR affects runtime usage of the replacer. Both do use |
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.
You're right - on closer inspection the files do not overlap. Let's merge this and give it a try!
imported snippets reflect actual lines in file
fix 5202