Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0381dde

Browse filesBrowse files
committed
Merge pull request #590 from docker-java/issue-480
Fix issue #480
2 parents 19acfcc + 7d1f64f commit 0381dde
Copy full SHA for 0381dde

File tree

4 files changed

+16
-23
lines changed
Filter options

4 files changed

+16
-23
lines changed

‎src/main/java/com/github/dockerjava/core/DockerClientConfig.java

Copy file name to clipboardExpand all lines: src/main/java/com/github/dockerjava/core/DockerClientConfig.java
+10-6Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,16 @@ private String checkDockerCertPath(boolean dockerTlsVerify, String dockerCertPat
109109

110110
if (!certPath.exists()) {
111111
throw new DockerClientException(
112-
"Certificate path (DOCKER_CERT_PATH) '" + dockerCertPath + "' doesn't exist.");
112+
"Enabled TLS verification (DOCKER_TLS_VERIFY=1) but certificate path (DOCKER_CERT_PATH) '" + dockerCertPath
113+
+ "' doesn't exist.");
113114
}
114115

115116
if (certPath.isDirectory()) {
116117
return dockerCertPath;
117118
} else {
118119
throw new DockerClientException(
119-
"Certificate path (DOCKER_CERT_PATH) '" + dockerCertPath + "' doesn't point to a directory.");
120+
"Enabled TLS verification (DOCKER_TLS_VERIFY=1) but certificate path (DOCKER_CERT_PATH) '" + dockerCertPath
121+
+ "' doesn't point to a directory.");
120122
}
121123
}
122124
} else {
@@ -375,7 +377,6 @@ public final DockerClientConfigBuilder withDockerHost(String dockerHost) {
375377
return this;
376378
}
377379

378-
379380
public final DockerClientConfigBuilder withApiVersion(RemoteApiVersion apiVersion) {
380381
this.apiVersion = apiVersion.getVersion();
381382
return this;
@@ -417,8 +418,12 @@ public final DockerClientConfigBuilder withDockerConfig(String dockerConfig) {
417418
}
418419

419420
public final DockerClientConfigBuilder withDockerTlsVerify(String dockerTlsVerify) {
420-
String trimmed = dockerTlsVerify.trim();
421-
this.dockerTlsVerify = "true".equalsIgnoreCase(trimmed) || "1".equals(trimmed);
421+
if (dockerTlsVerify != null) {
422+
String trimmed = dockerTlsVerify.trim();
423+
this.dockerTlsVerify = "true".equalsIgnoreCase(trimmed) || "1".equals(trimmed);
424+
} else {
425+
this.dockerTlsVerify = false;
426+
}
422427
return this;
423428
}
424429

@@ -433,4 +438,3 @@ public DockerClientConfig build() {
433438
}
434439
}
435440
}
436-

‎src/main/resources/META-INF/services/com.github.dockerjava.api.command.DockerCmdExecFactory

Copy file name to clipboardExpand all lines: src/main/resources/META-INF/services/com.github.dockerjava.api.command.DockerCmdExecFactory
-1Lines changed: 0 additions & 1 deletion
This file was deleted.

‎src/main/resources/docker-java.properties

Copy file name to clipboardExpand all lines: src/main/resources/docker-java.properties
+3-9Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-
#docker.io.url=https://localhost:2376
2-
#docker.io.dockerCertPath=${user.home}/.docker
3-
#docker.io.dockerCfgPath=${user.home}/.dockercfg
4-
#docker.io.username=${user.name}
5-
#docker.io.serverAddress=https://index.docker.io/v1/
6-
#
7-
DOCKER_HOST=tcp://localhost:2376
8-
DOCKER_TLS_VERIFY=1
1+
DOCKER_HOST=unix:///var/run/docker.sock
92
DOCKER_CONFIG=${user.home}/.docker
10-
DOCKER_CERT_PATH=${user.home}/.docker/certs
3+
#DOCKER_TLS_VERIFY=1
4+
#DOCKER_CERT_PATH=${user.home}/.docker/certs
115

126
api.version=
137
registry.url=https://index.docker.io/v1/

‎src/test/java/com/github/dockerjava/core/DockerClientConfigTest.java

Copy file name to clipboardExpand all lines: src/test/java/com/github/dockerjava/core/DockerClientConfigTest.java
+3-7Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
import static org.hamcrest.Matchers.equalTo;
55
import static org.hamcrest.core.Is.is;
66
import static org.testng.Assert.assertEquals;
7-
import static org.testng.Assert.assertFalse;
8-
import static org.testng.Assert.assertTrue;
7+
import static org.testng.Assert.assertNull;
98

109
import java.lang.reflect.Field;
1110
import java.net.URI;
@@ -54,8 +53,6 @@ public void environmentDockerHost() throws Exception {
5453
// and it looks to be SSL disabled
5554
env.remove("DOCKER_CERT_PATH");
5655

57-
58-
5956
// given default cert path
6057
Properties systemProperties = new Properties();
6158
systemProperties.setProperty("user.name", "someUserName");
@@ -82,7 +79,6 @@ public void environment() throws Exception {
8279
env.put(DockerClientConfig.DOCKER_CERT_PATH, dockerCertPath());
8380
env.put(DockerClientConfig.DOCKER_TLS_VERIFY, "1");
8481

85-
8682
// when you build a config
8783
DockerClientConfig config = buildConfig(env, new Properties());
8884

@@ -106,12 +102,12 @@ public void defaults() throws Exception {
106102
DockerClientConfig config = buildConfig(Collections.<String, String> emptyMap(), systemProperties);
107103

108104
// then the cert path is as expected
109-
assertEquals(config.getDockerHost(), URI.create("tcp://localhost:2376"));
105+
assertEquals(config.getDockerHost(), URI.create("unix:///var/run/docker.sock"));
110106
assertEquals(config.getRegistryUsername(), "someUserName");
111107
assertEquals(config.getRegistryUrl(), AuthConfig.DEFAULT_SERVER_ADDRESS);
112108
assertEquals(config.getApiVersion(), RemoteApiVersion.unknown());
113109
assertEquals(config.getDockerConfig(), homeDir() + "/.docker");
114-
assertEquals(config.getDockerCertPath(), homeDir() + "/.docker/certs");
110+
assertNull(config.getDockerCertPath());
115111
}
116112

117113
@Test

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.