Skip to content

Commit

Permalink
[#1528] determineFinalArgValue respect default value if key exists bu…
Browse files Browse the repository at this point in the history
…t value is null

Signed-off-by: thorsten.wendelmuth <[email protected]>
  • Loading branch information
twendelmuth authored and rohanKanojia committed Feb 24, 2022
1 parent 5f71139 commit 097f1c7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions doc/changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# ChangeLog

* **0.40-SNAPSHOT** :
- determineFinalArgValue respect default value if key exists but value is null ([1528](https://github.com/fabric8io/docker-maven-plugin/issues/1528)) @twendelmuth

* **0.39.0** (2022-02-06):
- `skipPom` is ignored by "push" goal ([1482](https://github.com/fabric8io/docker-maven-plugin/issues/1482)) @rohanKanojia
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ private static void updateMapWithArgValue(Map<String, String> result, Map<String

private static String determineFinalArgValue(String argString, String[] argStringParts, Map<String, String> args) {
String argStringValue = argString.substring(argStringParts[0].length() + 1);
if(args == null){
if(args == null || args.get(argStringParts[0]) == null){
return argStringValue;
}
return args.getOrDefault(argStringParts[0], argStringValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ public void testExtractArgsFromDockerfile() {
assertEquals("{busyboxVersion=latest}", DockerFileUtil.extractArgsFromLines(Collections.singletonList(new String[]{"ARG", "busyboxVersion=latest"}), null).toString());
}

@Test
public void testExtractArgsFromDockerFile_parameterMapWithNullValues() {
assertEquals("{VERSION=latest, FULL_IMAGE=busybox:latest}", DockerFileUtil.extractArgsFromLines(Arrays.asList(new String[]{"ARG", "VERSION:latest"}, new String[] {"ARG", "FULL_IMAGE=busybox:latest"}), Collections.singletonMap("VERSION", null)).toString());
assertEquals("{VERSION=latest, FULL_IMAGE=busybox:latest}", DockerFileUtil.extractArgsFromLines(Arrays.asList(new String[]{"ARG", "VERSION=latest"}, new String[] {"ARG", "FULL_IMAGE=busybox:latest"}), Collections.singletonMap("VERSION", null)).toString());
}

@Test(expected = IllegalArgumentException.class)
public void testInvalidArgWithSpacesFromDockerfile() {
DockerFileUtil.extractArgsFromLines(Collections.singletonList(new String[]{"ARG", "MY_IMAGE image with spaces"}), Collections.emptyMap());
Expand Down

0 comments on commit 097f1c7

Please sign in to comment.