-
Notifications
You must be signed in to change notification settings - Fork 118
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
Path pattern builder #809
base: main
Are you sure you want to change the base?
Path pattern builder #809
Conversation
…ename under to startWith
…uilder, given same precedence, option added after overrides previous
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #809 +/- ##
============================================
- Coverage 65.71% 65.67% -0.05%
- Complexity 3289 3337 +48
============================================
Files 350 356 +6
Lines 13731 13911 +180
Branches 1488 1510 +22
============================================
+ Hits 9024 9136 +112
- Misses 3863 3921 +58
- Partials 844 854 +10
... and 17 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
common/src/main/java/com/linecorp/centraldogma/common/PathPattern.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternBuilder.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternOptions.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternOption.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternOption.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternOption.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternOptions.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternBuilder.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternBuilder.java
Outdated
Show resolved
Hide resolved
…ernOptions.java Co-authored-by: Ikhun Um <ih.pert@gmail.com>
…ernOption.java Co-authored-by: Ikhun Um <ih.pert@gmail.com>
… logic from PathPatternOption to PathPatternBuilder
As a result of moving the pattern build order logic from |
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.
Overall looks good. Left minor comments.
common/src/main/java/com/linecorp/centraldogma/common/PathPattern.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternBuilder.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternBuilder.java
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternBuilder.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternBuilder.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternOption.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternOptions.java
Outdated
Show resolved
Hide resolved
common/src/test/java/com/linecorp/centraldogma/common/PathPatternBuilderTest.java
Outdated
Show resolved
Hide resolved
common/src/test/java/com/linecorp/centraldogma/common/PathPatternBuilderTest.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternOptions.java
Outdated
Show resolved
Hide resolved
…ern.java Co-authored-by: Ikhun Um <ih.pert@gmail.com>
…ernBuilderTest.java Co-authored-by: Ikhun Um <ih.pert@gmail.com>
…ernBuilderTest.java Co-authored-by: Ikhun Um <ih.pert@gmail.com>
…ernBuilder.java Co-authored-by: Ikhun Um <ih.pert@gmail.com>
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! 🚀:tada:
common/src/main/java/com/linecorp/centraldogma/common/PathPattern.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternBuilder.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternBuilder.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternOptions.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternOptions.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternOptions.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternOptions.java
Outdated
Show resolved
Hide resolved
…ern.java Co-authored-by: Ikhun Um <ih.pert@gmail.com>
…ernOptions.java Co-authored-by: Ikhun Um <ih.pert@gmail.com>
…ernOptions.java Co-authored-by: Ikhun Um <ih.pert@gmail.com>
…ernOptions.java Co-authored-by: Ikhun Um <ih.pert@gmail.com>
…ernBuilder.java Co-authored-by: Ikhun Um <ih.pert@gmail.com>
…ernOptions.java Co-authored-by: Ikhun Um <ih.pert@gmail.com>
common/src/main/java/com/linecorp/centraldogma/common/PathPattern.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternBuilder.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternBuilder.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternOptions.java
Outdated
Show resolved
Hide resolved
…tions: endsWith, startsWith, contains and hasExtension
common/src/main/java/com/linecorp/centraldogma/common/PathPattern.java
Outdated
Show resolved
Hide resolved
if (pathPatterns.length == 1) { | ||
return pathPatterns[0]; | ||
} | ||
return new DefaultPathPattern(ImmutableList.copyOf(pathPatterns)); |
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.
return new DefaultPathPattern(ImmutableList.copyOf(pathPatterns)); | |
return new DefaultPathPattern(ImmutableSet.copyOf(pathPatterns)); |
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.
Previously, a new constructor for DefaultPathPattern(List<PathPattern> verifiedPatterns)
was introduced that would skip the validatePathPattern step.
I changed the argument type from List<PathPattern>
-> varargs PathPattern...
in commit 0d85d78.
@Nullable | ||
private PathPatternOption startPattern; | ||
private final List<PathPatternOption> innerPatterns = new ArrayList<>(); | ||
@Nullable | ||
private PathPatternOption endPattern; |
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.
Can't we just use PathPattern
here?
/** | ||
* A {@link PathPatternBuilder} option. | ||
*/ | ||
final class PathPatternOption { |
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'm not sure if this class is needed at all. Why do we need to create a PathPattern
lazily? Can't we just create it as early as possible?
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 have merged PathPatternOptions
and PathPatternOption
with PathPatternBuilder
…ern.java Co-authored-by: Trustin Lee <t@motd.kr>
892ecf3
to
49b5d3f
Compare
assertThat(PathPattern.builder() | ||
.contains("/foo") | ||
.contains("/bar") | ||
.build() | ||
.patternString()).isEqualTo("/**/foo/**/bar/**"); | ||
assertThat(PathPattern.builder() | ||
.startsWith("/foo/bar") | ||
.startsWith("/override") | ||
.hasExtension("json") | ||
.build() | ||
.patternString()).isEqualTo("/override/**/*.json"); |
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 think this can be quite confusing to users. Should we always override, even for contains()
?
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.
Hi @trustin ,
Your point about differing behavior for contains
(combining allowed) vs other options (combining not allowed , will override) being confusing is valid.
I also understand @ikhoon point's that, when considered in isolation, contains
can be combined (ref #809 (comment) ).
Personally, I am on the fence, with no strong opinion.
Perhaps @minwoox , and @jrhee17 could share their opinion :)
Motivation:
Addresses #659.
PathPattern#of
acceptingPathPattern... pathPatterns
PathPatternBuilder
to provide a way to combination many patterns into one.The following initial options have been added:
Modifications:
PathPatternOption
,PathPathOptions
-> define and manage the options available.PathPatternBuilder
-> responsible for composing one pathPattern from the added options.endsWith
orextension
; currently, option added after will override previousResult: