Browse Source

Merge pull request #48965 from nosan

* pr/48965:
  Ensure Windows Docker credential helper resolves correctly

Closes gh-48965
pull/49013/head
Stéphane Nicoll 4 days ago
parent
commit
78d8f96509
  1. 3
      spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/configuration/CredentialHelper.java
  2. 18
      spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/docker/configuration/CredentialHelperTests.java

3
spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/configuration/CredentialHelper.java

@ -21,6 +21,7 @@ import java.io.InputStream; @@ -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 { @@ -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;
}

18
spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/docker/configuration/CredentialHelperTests.java

@ -38,10 +38,20 @@ class CredentialHelperTests { @@ -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

Loading…
Cancel
Save