Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
remove --config from command string generation
add --node option to buildx command

Signed-off-by: Roberto.Franchini <ro.franchini@gmail.com>
  • Loading branch information
Roberto.Franchini authored and rohanKanojia committed Jul 28, 2023
1 parent cf48a2d commit 0641d04
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected <C> void useBuilder(ProjectPaths projectPaths, ImageConfiguration imag
BuildDirs buildDirs = new BuildDirs(projectPaths, imageConfig.getName());

Path configPath = getDockerStateDir(imageConfig.getBuildConfiguration(), buildDirs);
List<String> buildX = Arrays.asList("docker", "--config", configPath.toString(), "buildx");
List<String> buildX = Arrays.asList("docker", "buildx");

String builderName = createBuilder(configPath, buildX, imageConfig, buildDirs);
Path configJson = configPath.resolve("config.json");
Expand Down Expand Up @@ -215,7 +215,7 @@ protected String createBuilder(Path configPath, List<String> buildX, ImageConfig
Path builderPath = configPath.resolve(Paths.get("buildx", "instances", builderName));
if(Files.notExists(builderPath)) {
List<String> 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",
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/io/fabric8/maven/docker/BuildMojoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -295,15 +295,15 @@ private void thenBuildxRun(String relativeConfigFile, String contextDir,
String configFile = relativeConfigFile != null ? getOsDependentBuild(projectBaseDirectory.toPath(), relativeConfigFile) : null;

List<String> 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<String> buildXLine = BuildXService.append(new ArrayList<>(), "docker", "--config", config, "buildx",
List<String> buildXLine = BuildXService.append(new ArrayList<>(), "docker", "buildx",
"build", "--progress=plain", "--builder", "maven",
"--platform", NATIVE_PLATFORM, "--tag", "example:latest", "--build-arg", "foo=bar");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> 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));
Expand Down

0 comments on commit 0641d04

Please sign in to comment.