mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-17 12:09:16 +00:00
Merge pull request #48965 from nosan
* pr/48965: Ensure Windows Docker credential helper resolves correctly Closes gh-48965
This commit is contained in:
+2
-1
@@ -21,6 +21,7 @@ import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -78,7 +79,7 @@ class CredentialHelper {
|
||||
if (Platform.isWindows()) {
|
||||
processBuilder.command("cmd", "/c");
|
||||
}
|
||||
processBuilder.command(this.executable, action);
|
||||
processBuilder.command().addAll(Arrays.asList(this.executable, action));
|
||||
return processBuilder;
|
||||
}
|
||||
|
||||
|
||||
+14
-4
@@ -38,10 +38,20 @@ class CredentialHelperTests {
|
||||
|
||||
@BeforeAll
|
||||
static void setUp() throws Exception {
|
||||
String executableName = "docker-credential-test" + ((Platform.isWindows()) ? ".bat" : ".sh");
|
||||
String executable = new ClassPathResource(executableName, CredentialHelperTests.class).getFile()
|
||||
.getAbsolutePath();
|
||||
helper = new CredentialHelper(executable);
|
||||
helper = new CredentialHelper(getExecutableName());
|
||||
}
|
||||
|
||||
private static String getExecutableName() throws Exception {
|
||||
if (Platform.isWindows()) {
|
||||
String executablePath = geExecutableAbsolutePath("docker-credential-test.bat");
|
||||
// cmd /c must resolve automatically .bat suffix
|
||||
return executablePath.substring(0, executablePath.lastIndexOf(".bat"));
|
||||
}
|
||||
return geExecutableAbsolutePath("docker-credential-test.sh");
|
||||
}
|
||||
|
||||
private static String geExecutableAbsolutePath(String executableName) throws Exception {
|
||||
return new ClassPathResource(executableName, CredentialHelperTests.class).getFile().getAbsolutePath();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user