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

Don't blow up on missing path transform configuration #14339

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ public IngressPathTransformInverter(
* @return the regex that essentially reverts the effect of the path transformation
*/
private static Pattern extractPathFromFmt(String pathTransformFmt) {
if (pathTransformFmt == null) {
return Pattern.compile("^(.*)$");
Copy link
Contributor

Choose a reason for hiding this comment

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

What about using PATH_TRANSFORM_PATH_CATCH here? It's used in the null check in ExternalServerExposer.

Copy link
Contributor Author

@metlos metlos Aug 27, 2019

Choose a reason for hiding this comment

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

This is basically a short hand for what the result would be if PATH_TRANSFORM_PATH_CATCH was the input to this method. I didn't want to do the processing when the result is directly known...

}
Matcher m = PATH_FORMAT_DECONSTRUCTION_REGEX.matcher(pathTransformFmt);
if (m.matches() && m.groupCount() == 2) {
String prefix = Pattern.quote(m.group(1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public static Object[][] transformationTestCases() {
{"%ssuffix", "pathsuffix", "path"},
{"prefix%s", "prefixpath", "path"},
{"prefix%ssuffix", "prefixpathsuffix", "path"},
{"prefix%s", "non-matching", "non-matching"}
{"prefix%s", "non-matching", "non-matching"},
{null, "some path", "some path"}
};
}
}