From d1fc36414d2e8230412e323a6224ce8d14c56d20 Mon Sep 17 00:00:00 2001 From: Amit reinich Date: Tue, 31 Dec 2024 20:02:50 +0200 Subject: [PATCH 1/6] fix: Fixed error already existing instance due to case sensitive Path.resolve() --- .../java/io/fabric8/maven/docker/service/BuildXService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/fabric8/maven/docker/service/BuildXService.java b/src/main/java/io/fabric8/maven/docker/service/BuildXService.java index 9bf5a228a..ff5e29f81 100644 --- a/src/main/java/io/fabric8/maven/docker/service/BuildXService.java +++ b/src/main/java/io/fabric8/maven/docker/service/BuildXService.java @@ -275,7 +275,7 @@ protected String createBuilder(Path configPath, List buildX, ImageConfig BuildXConfiguration buildXConfiguration = imageConfig.getBuildConfiguration().getBuildX(); String builderName = Optional.ofNullable(buildXConfiguration.getBuilderName()).orElse("maven"); String nodeName = buildXConfiguration.getNodeName(); - Path builderPath = configPath.resolve(Paths.get("buildx", "instances", builderName)); + Path builderPath = configPath.resolve(Paths.get("buildx", "instances", builderName.toLowerCase())); if(Files.notExists(builderPath)) { List cmds = new ArrayList<>(buildX); append(cmds, "create", "--driver", "docker-container", "--name", builderName); From 1412c5a83b735582be197dd525b7e878dffbf4a9 Mon Sep 17 00:00:00 2001 From: Amit reinich Date: Sat, 4 Jan 2025 14:51:41 +0200 Subject: [PATCH 2/6] added test for verify builder config is looked up by builder name lower cased. --- .../BuildXServiceCreateBuilderTest.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/test/java/io/fabric8/maven/docker/service/BuildXServiceCreateBuilderTest.java b/src/test/java/io/fabric8/maven/docker/service/BuildXServiceCreateBuilderTest.java index 56b62e2a8..9d09fc9f9 100644 --- a/src/test/java/io/fabric8/maven/docker/service/BuildXServiceCreateBuilderTest.java +++ b/src/test/java/io/fabric8/maven/docker/service/BuildXServiceCreateBuilderTest.java @@ -17,6 +17,7 @@ import java.io.File; import java.nio.file.Path; +import java.nio.file.Paths; import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -24,7 +25,9 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; class BuildXServiceCreateBuilderTest { private BuildXService buildXService; @@ -60,6 +63,24 @@ void driverOptIsPresentIfProvided() throws Exception { verifyBuildXArgumentContains("--driver-opt", "network=foonet"); } + + + @Test + void builderPathWithLowerCasedBuilderName() throws Exception { + String builderName = "myTestBuilder"; + Path configPathSpy = Mockito.spy(configPath); + Path expectedPath = Paths.get("buildx","instances",builderName.toLowerCase()); + + //Given + buildConfigUsingBuildX(temporaryFolder,(buildX, buildImage) -> buildX.builderName(builderName)); + + // When + buildXService.createBuilder(configPathSpy, Arrays.asList("docker", "buildx"), imageConfig, buildDirs); + + // Then + verify(configPathSpy).resolve(eq(expectedPath)); + } + @Test void driverOptIsAbsentIfNotProvided() throws Exception { //Given From f6a85c2c69effe57d3d6651ee966899f79964652 Mon Sep 17 00:00:00 2001 From: Amit reinich Date: Sat, 4 Jan 2025 18:30:12 +0200 Subject: [PATCH 3/6] fix: Removed unnecessary eq on verify method Removed unnecessary eq on verify method due to SonarQube issue --- .../maven/docker/service/BuildXServiceCreateBuilderTest.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/test/java/io/fabric8/maven/docker/service/BuildXServiceCreateBuilderTest.java b/src/test/java/io/fabric8/maven/docker/service/BuildXServiceCreateBuilderTest.java index 9d09fc9f9..987ac5652 100644 --- a/src/test/java/io/fabric8/maven/docker/service/BuildXServiceCreateBuilderTest.java +++ b/src/test/java/io/fabric8/maven/docker/service/BuildXServiceCreateBuilderTest.java @@ -25,7 +25,6 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; @@ -78,7 +77,7 @@ void builderPathWithLowerCasedBuilderName() throws Exception { buildXService.createBuilder(configPathSpy, Arrays.asList("docker", "buildx"), imageConfig, buildDirs); // Then - verify(configPathSpy).resolve(eq(expectedPath)); + verify(configPathSpy).resolve(expectedPath); } @Test From 73fa18bec8a945e913e68b9021f4a503c6e45fd1 Mon Sep 17 00:00:00 2001 From: amit reinich Date: Fri, 10 Jan 2025 17:02:37 +0200 Subject: [PATCH 4/6] added changelog --- doc/changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/changelog.md b/doc/changelog.md index 311ae42df..15800a3d9 100644 --- a/doc/changelog.md +++ b/doc/changelog.md @@ -4,7 +4,7 @@ - Docker-compose healthcheck configuration support ([1825](https://github.com/fabric8io/docker-maven-plugin/pull/1825)) - Docker container wait timeout default value made configurable using startContainerWaitTimeout configuration option ([1825](https://github.com/fabric8io/docker-maven-plugin/pull/1825)) - Respect `network` configuration in POM and with property `docker.build.network` or system property `docker.network.mode` in docker buildx [1850](https://github.com/fabric8io/docker-maven-plugin/pull/1850)) - + - Fix case sensitivity issue in builder name lookup by converting builderName to lowercase, ensuring compatibility across file systems. [1847](https://github.com/fabric8io/docker-maven-plugin/pull/1847) * **0.45.1 (2024-09-29)**: - Make copy docker-buildx binary to temporary config directory work on windows too ([1819](https://github.com/fabric8io/docker-maven-plugin/pull/1819)) - Pull FROM images in relative path Dockerfiles ([1823](https://github.com/fabric8io/docker-maven-plugin/issues/1823)) From f7a2a4e39ff3a86a4eeece820b33574318c0ac04 Mon Sep 17 00:00:00 2001 From: amit reinich Date: Fri, 10 Jan 2025 17:04:05 +0200 Subject: [PATCH 5/6] added changelog --- doc/changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/changelog.md b/doc/changelog.md index 15800a3d9..36216ff0d 100644 --- a/doc/changelog.md +++ b/doc/changelog.md @@ -4,7 +4,7 @@ - Docker-compose healthcheck configuration support ([1825](https://github.com/fabric8io/docker-maven-plugin/pull/1825)) - Docker container wait timeout default value made configurable using startContainerWaitTimeout configuration option ([1825](https://github.com/fabric8io/docker-maven-plugin/pull/1825)) - Respect `network` configuration in POM and with property `docker.build.network` or system property `docker.network.mode` in docker buildx [1850](https://github.com/fabric8io/docker-maven-plugin/pull/1850)) - - Fix case sensitivity issue in builder name lookup by converting builderName to lowercase, ensuring compatibility across file systems. [1847](https://github.com/fabric8io/docker-maven-plugin/pull/1847) + - Fix case sensitivity issue in builder name lookup by converting builderName to lowercase, ensuring compatibility across file systems [1847](https://github.com/fabric8io/docker-maven-plugin/pull/1847) * **0.45.1 (2024-09-29)**: - Make copy docker-buildx binary to temporary config directory work on windows too ([1819](https://github.com/fabric8io/docker-maven-plugin/pull/1819)) - Pull FROM images in relative path Dockerfiles ([1823](https://github.com/fabric8io/docker-maven-plugin/issues/1823)) From 0b632fdf84c68c9a6a1c43ba74f8c41bd6435a36 Mon Sep 17 00:00:00 2001 From: amit reinich Date: Fri, 10 Jan 2025 17:05:22 +0200 Subject: [PATCH 6/6] added changelog --- doc/changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/changelog.md b/doc/changelog.md index 36216ff0d..1726c19f6 100644 --- a/doc/changelog.md +++ b/doc/changelog.md @@ -4,7 +4,7 @@ - Docker-compose healthcheck configuration support ([1825](https://github.com/fabric8io/docker-maven-plugin/pull/1825)) - Docker container wait timeout default value made configurable using startContainerWaitTimeout configuration option ([1825](https://github.com/fabric8io/docker-maven-plugin/pull/1825)) - Respect `network` configuration in POM and with property `docker.build.network` or system property `docker.network.mode` in docker buildx [1850](https://github.com/fabric8io/docker-maven-plugin/pull/1850)) - - Fix case sensitivity issue in builder name lookup by converting builderName to lowercase, ensuring compatibility across file systems [1847](https://github.com/fabric8io/docker-maven-plugin/pull/1847) + - Fix case sensitivity issue in builder name lookup by converting builderName to lowercase, ensuring compatibility across file systems ([1847](https://github.com/fabric8io/docker-maven-plugin/pull/1847)) * **0.45.1 (2024-09-29)**: - Make copy docker-buildx binary to temporary config directory work on windows too ([1819](https://github.com/fabric8io/docker-maven-plugin/pull/1819)) - Pull FROM images in relative path Dockerfiles ([1823](https://github.com/fabric8io/docker-maven-plugin/issues/1823))