This commit is contained in:
Sergei Shitikov
2024-09-06 21:30:46 +02:00
parent 656f38f056
commit abe8159bcb
3 changed files with 8 additions and 13 deletions
+4 -4
View File
@@ -195,7 +195,7 @@ class GenericContainer implements TestContainer
try { try {
$containerCreatePostBody = new ContainersCreatePostBody(); $containerCreatePostBody = new ContainersCreatePostBody();
//handle withExposedPorts //handle withExposedPorts
if(!empty($this->exposedPorts)) { if (!empty($this->exposedPorts)) {
$portGenerator = new RandomUniquePortGenerator(); $portGenerator = new RandomUniquePortGenerator();
$portMap = new \ArrayObject(); $portMap = new \ArrayObject();
@@ -209,13 +209,13 @@ class GenericContainer implements TestContainer
$hostConfig = new HostConfig(); $hostConfig = new HostConfig();
$hostConfig->setPortBindings($portMap); $hostConfig->setPortBindings($portMap);
//handle withPrivilegedMode //handle withPrivilegedMode
if($this->isPrivileged) { if ($this->isPrivileged) {
$hostConfig->setPrivileged($this->isPrivileged); $hostConfig->setPrivileged($this->isPrivileged);
} }
$containerCreatePostBody->setHostConfig($hostConfig); $containerCreatePostBody->setHostConfig($hostConfig);
} }
//handle withPrivilegedMode //handle withPrivilegedMode
if($this->isPrivileged) { if ($this->isPrivileged) {
$hostConfig = new HostConfig(); $hostConfig = new HostConfig();
$hostConfig->setPrivileged($this->isPrivileged); $hostConfig->setPrivileged($this->isPrivileged);
} }
@@ -239,7 +239,7 @@ class GenericContainer implements TestContainer
$this->dockerClient->containerStart($this->id); $this->dockerClient->containerStart($this->id);
if(!isset($this->waitStrategy)) { if (!isset($this->waitStrategy)) {
$this->withWait(new WaitForContainer()); $this->withWait(new WaitForContainer());
} }
@@ -110,12 +110,16 @@ class StartedGenericContainer implements StartedTestContainer
//TODO: not ready yet //TODO: not ready yet
public function getFirstMappedPort(): int public function getFirstMappedPort(): int
{ {
var_dump($this->dockerClient);die(123);
/** @var \Docker\API\Model\ContainersIdJsonGetResponse200 | null $containerInspectResponse */
$containerInspectResponse = $this->dockerClient->containerInspect($this->id); $containerInspectResponse = $this->dockerClient->containerInspect($this->id);
$settings = $containerInspectResponse->getNetworkSettings(); $settings = $containerInspectResponse->getNetworkSettings();
$ports = (array)$settings->getPorts(); $ports = (array)$settings->getPorts();
$port = array_key_first($ports); $port = array_key_first($ports);
var_dump($ports, $port, (int)$ports[$port][0]->getHostPort());
return (int) $ports[$port][0]->getHostPort(); return (int) $ports[$port][0]->getHostPort();
} }
-9
View File
@@ -22,15 +22,6 @@ class OpenSearchContainer extends GenericContainer
)); ));
} }
/**
* @deprecated Use constructor instead
* Left for backward compatibility
*/
public static function make(string $version = 'latest'): self
{
return new self($version);
}
public function withDisabledSecurityPlugin(): self public function withDisabledSecurityPlugin(): self
{ {
$this->withEnvironment('plugins.security.disabled', 'true'); $this->withEnvironment('plugins.security.disabled', 'true');