From f7e1bca450a0ff4dbbd32b5c8a3a4d41e07ddb71 Mon Sep 17 00:00:00 2001 From: "Roberto.Franchini" Date: Mon, 8 May 2023 12:50:07 +0200 Subject: [PATCH] #1583 remove --config from command string generation add --node option to buildx command Signed-off-by: Roberto.Franchini --- .../java/io/fabric8/maven/docker/service/BuildXService.java | 4 ++-- src/test/java/io/fabric8/maven/docker/BuildMojoTest.java | 6 +++--- .../fabric8/maven/docker/service/RegistryServiceTest.java | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) 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 7b8c6d7b6..d55b89568 100644 --- a/src/main/java/io/fabric8/maven/docker/service/BuildXService.java +++ b/src/main/java/io/fabric8/maven/docker/service/BuildXService.java @@ -63,7 +63,7 @@ protected void useBuilder(ProjectPaths projectPaths, ImageConfiguration imag BuildDirs buildDirs = new BuildDirs(projectPaths, imageConfig.getName()); Path configPath = getDockerStateDir(imageConfig.getBuildConfiguration(), buildDirs); - List buildX = Arrays.asList("docker", "--config", configPath.toString(), "buildx"); + List buildX = Arrays.asList("docker", "buildx"); String builderName = createBuilder(configPath, buildX, imageConfig, buildDirs); Path configJson = configPath.resolve("config.json"); @@ -215,7 +215,7 @@ protected String createBuilder(Path configPath, List buildX, ImageConfig Path builderPath = configPath.resolve(Paths.get("buildx", "instances", builderName)); if(Files.notExists(builderPath)) { List cmds = new ArrayList<>(buildX); - append(cmds, "create", "--driver", "docker-container", "--name", builderName); + append(cmds, "create", "--driver", "docker-container", "--name", builderName, "--node", builderName + "0"); String buildConfig = buildXConfiguration.getConfigFile(); if(buildConfig != null) { append(cmds, "--config", diff --git a/src/test/java/io/fabric8/maven/docker/BuildMojoTest.java b/src/test/java/io/fabric8/maven/docker/BuildMojoTest.java index 185b1d62b..586fa3ac4 100644 --- a/src/test/java/io/fabric8/maven/docker/BuildMojoTest.java +++ b/src/test/java/io/fabric8/maven/docker/BuildMojoTest.java @@ -295,15 +295,15 @@ private void thenBuildxRun(String relativeConfigFile, String contextDir, String configFile = relativeConfigFile != null ? getOsDependentBuild(projectBaseDirectory.toPath(), relativeConfigFile) : null; List cmds = - BuildXService.append(new ArrayList<>(), "docker", "--config", config, "buildx", - "create", "--driver", "docker-container", "--name", "maven"); + BuildXService.append(new ArrayList<>(), "docker", "buildx", + "create", "--driver", "docker-container", "--name", "maven" , "--node", "maven0"); if (configFile != null) { BuildXService.append(cmds, "--config", configFile.replace('/', File.separatorChar)); } Mockito.verify(exec).process(cmds); if (nativePlatformIncluded) { - List buildXLine = BuildXService.append(new ArrayList<>(), "docker", "--config", config, "buildx", + List buildXLine = BuildXService.append(new ArrayList<>(), "docker", "buildx", "build", "--progress=plain", "--builder", "maven", "--platform", NATIVE_PLATFORM, "--tag", "example:latest", "--build-arg", "foo=bar"); diff --git a/src/test/java/io/fabric8/maven/docker/service/RegistryServiceTest.java b/src/test/java/io/fabric8/maven/docker/service/RegistryServiceTest.java index 15e2a532e..b3b52d4c4 100644 --- a/src/test/java/io/fabric8/maven/docker/service/RegistryServiceTest.java +++ b/src/test/java/io/fabric8/maven/docker/service/RegistryServiceTest.java @@ -437,11 +437,11 @@ private void thenBuildxImageHasBeenPushed(String providedBuilder, String relativ String builderName = providedBuilder != null ? providedBuilder : "maven"; if (providedBuilder == null) { - Mockito.verify(exec).process(Arrays.asList("docker", "--config", config, "buildx", "create", "--driver", "docker-container", "--name", builderName)); + Mockito.verify(exec).process(Arrays.asList("docker", "buildx", "create", "--driver", "docker-container", "--name", builderName, "--node", builderName+"0")); } List cmds = - BuildXService.append(new ArrayList<>(), "docker", "--config", config, "buildx", "build", + BuildXService.append(new ArrayList<>(), "docker", "buildx", "build", "--progress=plain", "--builder", builderName, "--platform", "linux/amd64,linux/arm64", "--tag", new ImageName(imageConfiguration.getName()).getFullName(registry));