Skip to content
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

Merged

Conversation

bcolucci
Copy link
Contributor

@bcolucci bcolucci commented Mar 5, 2021

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...).

@bcolucci bcolucci changed the title feat: Support more complicated path_regexp (https://github.com/mozill… feat: Support more complicated path_regexp (issues/826) Mar 5, 2021
sfrevel
sfrevel previously approved these changes Mar 8, 2021
Copy link

@sfrevel sfrevel left a 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...

Copy link
Contributor

@felixfontein felixfontein left a 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) {
Copy link
Contributor

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.

Copy link
Contributor Author

@bcolucci bcolucci Mar 8, 2021

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.

@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.

@bcolucci bcolucci changed the base branch from master to develop March 8, 2021 19:44
Copy link
Contributor

@autrilla autrilla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@autrilla autrilla merged commit 79d5dac into getsops:develop Mar 10, 2021
@bcolucci bcolucci deleted the feat-support-complicated-regepx-in-config branch March 10, 2021 23:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants