-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Update docker-java to 3.0.12 (#393)"
- Loading branch information
Showing
12 changed files
with
126 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...rc/main/java/org/testcontainers/dockerclient/ProxiedUnixSocketClientProviderStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package org.testcontainers.dockerclient; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.apache.commons.lang.SystemUtils; | ||
import org.rnorth.tcpunixsocketproxy.TcpToUnixSocketProxy; | ||
|
||
import java.io.File; | ||
|
||
@Slf4j | ||
public class ProxiedUnixSocketClientProviderStrategy extends UnixSocketClientProviderStrategy { | ||
|
||
public static final int PRIORITY = EnvironmentAndSystemPropertyClientProviderStrategy.PRIORITY - 10; | ||
|
||
private final File socketFile = new File(DOCKER_SOCK_PATH); | ||
|
||
@Override | ||
protected boolean isApplicable() { | ||
return !SystemUtils.IS_OS_LINUX && socketFile.exists(); | ||
} | ||
|
||
@Override | ||
protected int getPriority() { | ||
return PRIORITY; | ||
} | ||
|
||
@Override | ||
public void test() throws InvalidConfigurationException { | ||
TcpToUnixSocketProxy proxy = new TcpToUnixSocketProxy(socketFile); | ||
|
||
try { | ||
int proxyPort = proxy.start().getPort(); | ||
|
||
config = tryConfiguration("tcp://localhost:" + proxyPort); | ||
|
||
log.debug("Accessing unix domain socket via TCP proxy (" + DOCKER_SOCK_PATH + " via localhost:" + proxyPort + ")"); | ||
} catch (Exception e) { | ||
|
||
proxy.stop(); | ||
|
||
throw new InvalidConfigurationException("ping failed", e); | ||
} | ||
|
||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return "local Unix socket (via TCP proxy)"; | ||
} | ||
|
||
} |
55 changes: 55 additions & 0 deletions
55
core/src/main/java/org/testcontainers/dockerclient/TestcontainersDockerCmdExecFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package org.testcontainers.dockerclient; | ||
|
||
import com.fasterxml.jackson.core.type.TypeReference; | ||
import com.github.dockerjava.api.command.ListNetworksCmd; | ||
import com.github.dockerjava.api.model.Network; | ||
import com.github.dockerjava.core.DockerClientConfig; | ||
import com.github.dockerjava.core.util.FiltersEncoder; | ||
import com.github.dockerjava.netty.MediaType; | ||
import com.github.dockerjava.netty.NettyDockerCmdExecFactory; | ||
import com.github.dockerjava.netty.WebTarget; | ||
import com.github.dockerjava.netty.exec.AbstrSyncDockerCmdExec; | ||
import lombok.SneakyThrows; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.lang.reflect.Field; | ||
import java.util.List; | ||
|
||
class TestcontainersDockerCmdExecFactory extends NettyDockerCmdExecFactory { | ||
|
||
@Override | ||
@SneakyThrows | ||
public ListNetworksCmd.Exec createListNetworksCmdExec() { | ||
Field baseResourceField = NettyDockerCmdExecFactory.class.getDeclaredField("baseResource"); | ||
baseResourceField.setAccessible(true); | ||
|
||
// FIXME Workaround for https://github.com/docker-java/docker-java/issues/857 | ||
return new ListNetworksCmdExec((WebTarget) baseResourceField.get(this), getDockerClientConfig()); | ||
} | ||
|
||
private static class ListNetworksCmdExec extends AbstrSyncDockerCmdExec<ListNetworksCmd, List<Network>> implements ListNetworksCmd.Exec { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(com.github.dockerjava.netty.exec.ListNetworksCmdExec.class); | ||
|
||
public ListNetworksCmdExec(WebTarget baseResource, DockerClientConfig dockerClientConfig) { | ||
super(baseResource, dockerClientConfig); | ||
} | ||
|
||
@Override | ||
protected List<Network> execute(ListNetworksCmd command) { | ||
WebTarget webTarget = getBaseResource().path("/networks"); | ||
|
||
if (command.getFilters() != null && !command.getFilters().isEmpty()) { | ||
// Next line was changed (urlPathSegmentEscaper was removed) | ||
webTarget = webTarget.queryParam("filters", FiltersEncoder.jsonEncode(command.getFilters())); | ||
} | ||
|
||
LOGGER.trace("GET: {}", webTarget); | ||
|
||
return webTarget.request().accept(MediaType.APPLICATION_JSON).get(new TypeReference<List<Network>>() { | ||
}); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters