-
Notifications
You must be signed in to change notification settings - Fork 900
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
feat: Support more complicated path_regexp (issues/826) #829
feat: Support more complicated path_regexp (issues/826) #829
Conversation
v3.6.1 - develop -> master
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.
Looks exactly like I thought it should be... Never used the Destination rule, but there's also just the simple way for patterns used. Maybe it's also worth to take a look...
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 need to rebase the PR against the develop
branch.
config/config.go
Outdated
rule = &r | ||
break | ||
} | ||
if regexp.MustCompile(r.PathRegex).MatchString(filePath) { |
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.
The if r.PathRegex != "" {
is missing.
Also, I'm not sure whether using MustCompile
here is a good idea in terms of error handling. It will panic if r.PathRegex
does not compile. The old code was simply ignoring errors, which might not be the be solution, but panicing instead is not a good idea IMO.
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.
The
if r.PathRegex != "" {
is missing.Also, I'm not sure whether using
MustCompile
here is a good idea in terms of error handling. It will panic ifr.PathRegex
does not compile. The old code was simply ignoring errors, which might not be the be solution, but panicing instead is not a good idea IMO.
@felixfontein , the if r.PathRegex != "" {
is useless because we check if the string is empty before, and if it's the case, then it breaks. So the string is not empty at this point.
I update the code so I return an error instead of panicing.
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.
Thank you!
Ref: #826
This should works. But @sfrevel, if you have better examples so I can complete the tests? (but I guess it could be okay like that already...).