Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,13 @@ public void setMaxPerRouteConnections(Integer maxPerRouteConnections) {

public String toUrl() throws DockerException {
ObjectHelper.notNull(this.host, "host");
ObjectHelper.notNull(this.port, "port");

return ((this.socket) ? "unix" : "tcp") + "://" + host + ":" + port;
if(this.socket) {
return "unix" + ":///" + host ;
} else {
ObjectHelper.notNull(this.port, "port");
return "tcp" + "://" + host + ":" + port;
}
}

public Boolean isTlsVerify() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ public class DockerConfiguration implements Cloneable {
private boolean followRedirectFilter;
@UriParam(label = "security", defaultValue = "false")
private boolean tlsVerify;
@UriParam(label = "advanced", defaultValue = "true")
private boolean socket;
@UriParam(label = "advanced", defaultValue = "false")
private boolean socketEnabled;
@UriParam(label = "advanced", defaultValue = "com.github.dockerjava.jaxrs.JerseyDockerCmdExecFactory")
private String cmdExecFactory = "com.github.dockerjava.jaxrs.JerseyDockerCmdExecFactory";

Expand Down Expand Up @@ -245,14 +245,14 @@ public void setTlsVerify(boolean tlsVerify) {
}

public boolean isSocket() {
return socket;
return socketEnabled;
}

/**
* Socket connection mode
*/
public void setSocket(boolean socket) {
this.socket = socket;
this.socketEnabled = socket;
}

public String getCmdExecFactory() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ public final class DockerConstants {
DOCKER_DEFAULT_PARAMETERS.put(DOCKER_SERVER_ADDRESS, String.class);
DOCKER_DEFAULT_PARAMETERS.put(DOCKER_USERNAME, String.class);
DOCKER_DEFAULT_PARAMETERS.put(DOCKER_CMD_EXEC_FACTORY, String.class);
DOCKER_DEFAULT_PARAMETERS.put(DOCKER_SOCKET_ENABLED, Boolean.class);

}

private DockerConstants() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import static org.junit.Assert.assertEquals;

import org.apache.camel.component.docker.exception.DockerException;

/**
* Validates the {@link DockerClientProfile}
*/
Expand Down Expand Up @@ -62,4 +64,31 @@ public void clientProfileTest() {
assertEquals(clientProfile1, clientProfile2);
}

@Test
public void testSocket() throws DockerException {
String host = "var/run/docker.sock";
String email = "docker@camel.apache.org";
String username = "user";
String password = "password";
Integer port = 2241;
Integer requestTimeout = 40;
boolean secure = true;
String certPath = "/docker/cert/path";
String cmdExecFactory = DockerConstants.DEFAULT_CMD_EXEC_FACTORY;

DockerClientProfile clientProfile1 = new DockerClientProfile();
clientProfile1.setHost(host);
clientProfile1.setEmail(email);
clientProfile1.setUsername(username);
clientProfile1.setPassword(password);
clientProfile1.setPort(port);
clientProfile1.setSocket(true);
clientProfile1.setRequestTimeout(requestTimeout);
clientProfile1.setSecure(secure);
clientProfile1.setCertPath(certPath);
clientProfile1.setCmdExecFactory(cmdExecFactory);

assertEquals("unix://", "unix:///var/run/docker.sock", clientProfile1.toUrl());
}

}