Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: error already existing instance due to case sensitive Path #1847

Merged
merged 7 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ protected String createBuilder(Path configPath, List<String> 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<String> cmds = new ArrayList<>(buildX);
append(cmds, "create", "--driver", "docker-container", "--name", builderName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -25,6 +26,7 @@
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;

class BuildXServiceCreateBuilderTest {
private BuildXService buildXService;
Expand Down Expand Up @@ -60,6 +62,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(expectedPath);
}

@Test
void driverOptIsAbsentIfNotProvided() throws Exception {
//Given
Expand Down
Loading