internal_ports should be a string and not an array

Signed-off-by: Simon L <szaimen@e.mail.de>
This commit is contained in:
Simon L 2022-12-25 01:40:37 +01:00
parent 53065b5631
commit 54f61eba68
8 changed files with 32 additions and 81 deletions

View file

@ -14,7 +14,7 @@ class Container {
private string $restartPolicy;
private int $maxShutdownTime;
private ContainerPorts $ports;
private ContainerInternalPorts $internalPorts;
private string $internalPorts;
private ContainerVolumes $volumes;
private ContainerEnvironmentVariables $containerEnvironmentVariables;
/** @var string[] */
@ -30,7 +30,7 @@ class Container {
string $restartPolicy,
int $maxShutdownTime,
ContainerPorts $ports,
ContainerInternalPorts $internalPorts,
string $internalPorts,
ContainerVolumes $volumes,
ContainerEnvironmentVariables $containerEnvironmentVariables,
array $dependsOn,
@ -79,7 +79,7 @@ class Container {
return $this->ports;
}
public function GetInternalPorts() : ContainerInternalPorts {
public function GetInternalPort() : string {
return $this->internalPorts;
}

View file

@ -1,19 +0,0 @@
<?php
namespace AIO\Container;
class ContainerInternalPorts {
/** @var string[] */
private array $internalPorts = [];
public function AddInternalPort(string $internalPort) : void {
$this->internalPorts[] = $internalPort;
}
/**
* @return string[]
*/
public function GetInternalPorts() : array {
return $this->internalPorts;
}
}

View file

@ -5,7 +5,6 @@ namespace AIO;
use AIO\Container\Container;
use AIO\Container\ContainerEnvironmentVariables;
use AIO\Container\ContainerPorts;
use AIO\Container\ContainerInternalPorts;
use AIO\Container\ContainerVolume;
use AIO\Container\ContainerVolumes;
use AIO\Container\State\RunningState;
@ -87,14 +86,10 @@ class ContainerDefinitionFetcher
$ports->AddPort($port);
}
$internalPorts = new ContainerInternalPorts();
foreach ($entry['internal_ports'] as $internalPort) {
if($internalPort === '%APACHE_PORT%') {
$internalPort = $this->configurationManager->GetApachePort();
} elseif($internalPort === '%TALK_PORT%') {
$internalPort = $this->configurationManager->GetTalkPort();
}
$internalPorts->AddInternalPort($internalPort);
if($entry['internal_port'] === '%APACHE_PORT%') {
$entry['internal_port'] = $this->configurationManager->GetApachePort();
} elseif($entry['internal_port'] === '%TALK_PORT%') {
$entry['internal_port'] = $this->configurationManager->GetTalkPort();
}
$volumes = new ContainerVolumes();
@ -183,7 +178,7 @@ class ContainerDefinitionFetcher
$entry['restart'],
$entry['stop_grace_period'],
$ports,
$internalPorts,
$entry['internal_port'],
$volumes,
$variables,
$dependsOn,

View file

@ -124,15 +124,13 @@ class DockerActionManager
}
$containerName = $container->GetIdentifier();
if ($container->GetInternalPorts() !== null) {
foreach($container->GetInternalPorts()->GetInternalPorts() as $internalPort) {
$connection = @fsockopen($containerName, $internalPort, $errno, $errstr, 0.1);
if ($connection) {
fclose($connection);
return new RunningState();
} else {
return new StartingState();
}
if ($container->GetInternalPort() !== "") {
$connection = @fsockopen($containerName, (int)$container->GetInternalPort(), $errno, $errstr, 0.1);
if ($connection) {
fclose($connection);
return new RunningState();
} else {
return new StartingState();
}
} else {
return new RunningState();