-
Notifications
You must be signed in to change notification settings - Fork 645
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
BuildX failing for Docker CLI on Windows fixed #1819
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,43 @@ | ||
package io.fabric8.maven.docker.service; | ||
|
||
import io.fabric8.maven.docker.util.ImageName; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.io.File; | ||
import java.nio.file.Paths; | ||
|
||
import io.fabric8.maven.docker.access.AuthConfig; | ||
import java.util.function.BiConsumer; | ||
|
||
import io.fabric8.maven.docker.access.AuthConfigList; | ||
import io.fabric8.maven.docker.access.DockerAccess; | ||
import io.fabric8.maven.docker.assembly.DockerAssemblyManager; | ||
import io.fabric8.maven.docker.config.BuildImageConfiguration; | ||
import io.fabric8.maven.docker.config.BuildXConfiguration; | ||
import io.fabric8.maven.docker.config.ImageConfiguration; | ||
import io.fabric8.maven.docker.util.EnvUtil; | ||
import io.fabric8.maven.docker.util.ImageName; | ||
import io.fabric8.maven.docker.util.Logger; | ||
import io.fabric8.maven.docker.util.ProjectPaths; | ||
import org.apache.maven.plugin.MojoExecutionException; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
|
||
import org.junit.jupiter.api.io.TempDir; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.ValueSource; | ||
import org.mockito.ArgumentCaptor; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.MockedConstruction; | ||
import org.mockito.MockedStatic; | ||
import org.mockito.Spy; | ||
import org.mockito.Mockito; | ||
import org.mockito.quality.Strictness; | ||
import org.mockito.*; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
import org.mockito.junit.jupiter.MockitoSettings; | ||
import org.mockito.quality.Strictness; | ||
|
||
import io.fabric8.maven.docker.access.DockerAccess; | ||
import io.fabric8.maven.docker.access.AuthConfigList; | ||
import io.fabric8.maven.docker.assembly.DockerAssemblyManager; | ||
import io.fabric8.maven.docker.util.Logger; | ||
import io.fabric8.maven.docker.util.ProjectPaths; | ||
import io.fabric8.maven.docker.config.BuildXConfiguration; | ||
import io.fabric8.maven.docker.config.BuildImageConfiguration; | ||
import io.fabric8.maven.docker.config.ImageConfiguration; | ||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.function.BiConsumer; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static org.mockito.ArgumentMatchers.any; | ||
import static org.mockito.ArgumentMatchers.anyString; | ||
import static org.mockito.ArgumentMatchers.eq; | ||
import static org.mockito.Mockito.mockConstruction; | ||
import static org.mockito.Mockito.mockStatic; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.when; | ||
import static org.mockito.ArgumentMatchers.*; | ||
import static org.mockito.Mockito.*; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you please revert these wildcard import changes? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, just used vs-code to do so. |
||
|
||
@ExtendWith(MockitoExtension.class) | ||
@MockitoSettings(strictness = Strictness.WARN) | ||
|
@@ -238,28 +224,32 @@ void useBuilder_whenConfiguredRegistryAbsentInDockerRegistry_thenAddConfigOption | |
assertEquals(Arrays.asList("docker", "--config", temporaryFolder.getAbsolutePath(), "buildx"), buildXArgCaptor.getValue()); | ||
} | ||
|
||
@Test | ||
void useBuilder_whenDockerBuildXIncompatibleWithConfigOverride_thenCopyBuildXBinaryToTemporaryConfig() throws IOException, MojoExecutionException { | ||
@ParameterizedTest | ||
@ValueSource(booleans = {true, false}) | ||
void useBuilder_whenDockerBuildXIncompatibleWithConfigOverride_thenCopyBuildXBinaryToTemporaryConfig(boolean isWindows) throws IOException, MojoExecutionException { | ||
try (MockedStatic<EnvUtil> envUtilMockedStatic = mockStatic(EnvUtil.class); | ||
MockedConstruction<BuildXService.BuildXListWithConfigCommand> ignore = mockConstruction(BuildXService.BuildXListWithConfigCommand.class, (mock, ctx) -> { | ||
MockedConstruction<BuildXService.BuildXListWithConfigCommand> ignore = mockConstruction(BuildXService.BuildXListWithConfigCommand.class, (mock, ctx) -> { | ||
when(mock.isSuccessFul()).thenReturn(false); | ||
})) { | ||
// Given | ||
Path configDirPath = temporaryFolder.toPath().resolve("docker-state-dir"); | ||
Files.createDirectory(configDirPath); | ||
Files.createDirectory(temporaryFolder.toPath().resolve(".docker")); | ||
Files.createDirectory(temporaryFolder.toPath().resolve(".docker").resolve("cli-plugins")); | ||
Files.createFile(temporaryFolder.toPath().resolve(".docker").resolve("cli-plugins").resolve("docker-buildx")); | ||
final String buildxExecutableFilename = "docker-buildx" + (isWindows ? ".exe" : ""); | ||
Files.createFile(temporaryFolder.toPath().resolve(".docker").resolve("cli-plugins").resolve(buildxExecutableFilename)); | ||
envUtilMockedStatic.when(EnvUtil::getUserHome).thenReturn(temporaryFolder.getAbsolutePath()); | ||
envUtilMockedStatic.when(EnvUtil::isWindows).thenReturn(isWindows); | ||
BuildXService.Builder<File> builder = Mockito.mock(BuildXService.Builder.class); | ||
|
||
givenAnImageConfiguration("linux/arm46", "linux/amd64"); | ||
|
||
// When | ||
buildx.useBuilder(projectPaths, imageConfig, configuredRegistry, authConfigList, buildArchive, builder); | ||
|
||
// Then | ||
assertTrue(configDirPath.resolve("cli-plugins").toFile().exists()); | ||
assertTrue(configDirPath.resolve("cli-plugins").resolve("docker-buildx").toFile().exists()); | ||
assertTrue(configDirPath.resolve("cli-plugins").resolve(buildxExecutableFilename).toFile().exists()); | ||
verify(logger).debug("Detected current version of BuildX not working with --config override"); | ||
verify(logger).debug("Copying BuildX binary to " + temporaryFolder.toPath().resolve("docker-state-dir")); | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we need to address #1819 (comment) here as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok tried to revert that aswell