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

Follow up PR for https://github.com/fabric8io/docker-maven-plugin/pull/1373 #1383

Merged
merged 1 commit into from
Oct 10, 2020

Conversation

rohanKanojia
Copy link
Member

Follow up PR for #1373

Use regex in order to resolve ARG value

Copy link
Collaborator

@rhuss rhuss left a comment

Choose a reason for hiding this comment

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

Thanks, looks good ! Some minor comments though ;)

return args.get(argString.substring(1));
} else if (argString.startsWith("${") && argString.endsWith("}") && args.containsKey(argString.substring(2, argString.length() - 1))) {
return args.get(argString.substring(2, argString.length() - 1));
Pattern argPattern = Pattern.compile("\\$(?:\\{(.*)\\}|(.*))");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Pattern argPattern = Pattern.compile("\\$(?:\\{(.*)\\}|(.*))");
Pattern argPattern = Pattern.compile("^\\$(?:\\{(.*)\\}|(.*))$");

Align with start and end of the string. Otherwise you would also match bla$ad or ${foo}bar

Copy link
Collaborator

Choose a reason for hiding this comment

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

But please verify my assumption within the tests, too, please

return args.get(argString.substring(2, argString.length() - 1));
Pattern argPattern = Pattern.compile("\\$(?:\\{(.*)\\}|(.*))");
Matcher matcher = argPattern.matcher(argString);
if (matcher.find()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should you use matches() here as find also matches on substrings ? (if you ^ and $ this should make nor difference, but I still think "match" is cleare)

Use regex in order to resolve ARG value
Copy link
Collaborator

@rhuss rhuss left a comment

Choose a reason for hiding this comment

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

Thanks ! Looks good ...

@rhuss rhuss merged commit 79e14c9 into fabric8io:master Oct 10, 2020
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.

2 participants