Skip to content

Commit

Permalink
Follow up PR for #1373
Browse files Browse the repository at this point in the history
Use regex in order to resolve ARG value
  • Loading branch information
rohanKanojia committed Sep 28, 2020
1 parent 207c0f3 commit bc9f71a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/main/java/io/fabric8/maven/docker/util/DockerFileUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,14 @@ static Map<String, String> extractArgsFromLines(List<String[]> argLines, Map<Str
}

static String resolveArgValueFromStrContainingArgKey(String argString, Map<String, String> args) {
if (argString.startsWith("$") && args.containsKey(argString.substring(1))) {
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("\\$(?:\\{(.*)\\}|(.*))");
Matcher matcher = argPattern.matcher(argString);
if (matcher.find()) {
if (matcher.group(1) != null) {
return args.get(matcher.group(1));
} else if (matcher.group(2) != null) {
return args.get(matcher.group(2));
}
}
return null;
}
Expand Down

0 comments on commit bc9f71a

Please sign in to comment.