Skip to content
This repository was archived by the owner on Mar 21, 2022. It is now read-only.

Commit e4f80c8

Browse files
committed
Remove unexpected default cert path in DockerHost
`DockerHost.fromEnv()` shouldn't have a cert path if the `DOCKER_CERT_PATH` env var isn't set.
1 parent 6990f23 commit e4f80c8

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

src/main/java/com/spotify/docker/client/DefaultDockerClient.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@
125125
import javax.ws.rs.core.MediaType;
126126
import javax.ws.rs.core.Response;
127127

128+
import static com.google.common.base.MoreObjects.firstNonNull;
128129
import static com.google.common.base.Optional.fromNullable;
129130
import static com.google.common.base.Preconditions.checkArgument;
130131
import static com.google.common.base.Preconditions.checkNotNull;
@@ -1681,7 +1682,8 @@ public static Builder builder() {
16811682
*/
16821683
public static Builder fromEnv() throws DockerCertificateException {
16831684
final String endpoint = DockerHost.endpointFromEnv();
1684-
final Path dockerCertPath = Paths.get(DockerHost.certPathFromEnv());
1685+
final Path dockerCertPath = Paths.get(firstNonNull(DockerHost.certPathFromEnv(),
1686+
DockerHost.defaultCertPath()));
16851687

16861688
final Builder builder = new Builder();
16871689

src/main/java/com/spotify/docker/client/DockerHost.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ static String defaultCertPath() {
213213
}
214214

215215
static String certPathFromEnv() {
216-
return firstNonNull(systemDelegate.getenv("DOCKER_CERT_PATH"), defaultCertPath());
216+
return systemDelegate.getenv("DOCKER_CERT_PATH");
217217
}
218218

219219
@Override

src/test/java/com/spotify/docker/client/DockerHostTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public void testCertPathFromEnv() throws Exception {
9898
DockerHost.setSystemDelegate(systemDelegate);
9999

100100
assertThat(DockerHost.certPathFromEnv(), equalTo("foo"));
101-
assertThat(DockerHost.certPathFromEnv(), equalTo("bar/.docker"));
101+
assertThat(DockerHost.certPathFromEnv(), equalTo(null));
102102
}
103103

104104
@Test
@@ -151,7 +151,7 @@ public void testFromEnv() throws Exception {
151151
final String dockerHostEnvVar = DockerHost.defaultDockerEndpoint();
152152
final boolean isUnixSocket = dockerHostEnvVar.startsWith("unix://");
153153
final URI dockerHostUri = new URI(dockerHostEnvVar);
154-
final String dockerCertPathEnvVar = DockerHost.defaultCertPath();
154+
final String dockerCertPathEnvVar = null;
155155

156156
final String dockerHostAndPort;
157157
final URI dockerHostHttpUri;

0 commit comments

Comments
 (0)