Skip to content

Commit

Permalink
add isset for non-required properties
Browse files Browse the repository at this point in the history
Signed-off-by: Simon L <szaimen@e.mail.de>
  • Loading branch information
szaimen committed Jan 2, 2023
1 parent f98528e commit d4893be
Showing 1 changed file with 103 additions and 70 deletions.
173 changes: 103 additions & 70 deletions php/src/ContainerDefinitionFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ private function GetDefinition(bool $latest): array
}

$ports = new ContainerPorts();
foreach ($entry['ports'] as $value) {
if (isset($entry['ports'])) {
foreach ($entry['ports'] as $value) {

if ($value['port_number'] === '%APACHE_PORT%') {
$value['port_number'] = $this->configurationManager->GetApachePort();
Expand All @@ -97,97 +98,129 @@ private function GetDefinition(bool $latest): array
);
}


$volumes = new ContainerVolumes();
foreach ($entry['volumes'] as $value) {
if($value['source'] === '%BORGBACKUP_HOST_LOCATION%') {
$value['source'] = $this->configurationManager->GetBorgBackupHostLocation();
if($value['source'] === '') {
continue;
}
}
if($value['source'] === '%NEXTCLOUD_MOUNT%') {
$value['source'] = $this->configurationManager->GetNextcloudMount();
if($value['source'] === '') {
continue;
if (isset($entry['volumes'])) {
foreach ($entry['volumes'] as $value) {
if($value['source'] === '%BORGBACKUP_HOST_LOCATION%') {
$value['source'] = $this->configurationManager->GetBorgBackupHostLocation();
if($value['source'] === '') {
continue;
}
}
} elseif ($value['source'] === '%NEXTCLOUD_DATADIR%') {
$value['source'] = $this->configurationManager->GetNextcloudDatadirMount();
if ($value['source'] === '') {
continue;
if($value['source'] === '%NEXTCLOUD_MOUNT%') {
$value['source'] = $this->configurationManager->GetNextcloudMount();
if($value['source'] === '') {
continue;
}
} elseif ($value['source'] === '%NEXTCLOUD_DATADIR%') {
$value['source'] = $this->configurationManager->GetNextcloudDatadirMount();
if ($value['source'] === '') {
continue;
}
} elseif ($value['source'] === '%DOCKER_SOCKET_PATH%') {
$value['source'] = $this->configurationManager->GetDockerSocketPath();
if($value['source'] === '') {
continue;
}
} elseif ($value['source'] === '%NEXTCLOUD_TRUSTED_CACERTS_DIR%') {
$value['source'] = $this->configurationManager->GetTrustedCacertsDir();
if($value['source'] === '') {
continue;
}
}
} elseif ($value['source'] === '%DOCKER_SOCKET_PATH%') {
$value['source'] = $this->configurationManager->GetDockerSocketPath();
if($value['source'] === '') {
continue;
}
} elseif ($value['source'] === '%NEXTCLOUD_TRUSTED_CACERTS_DIR%') {
$value['source'] = $this->configurationManager->GetTrustedCacertsDir();
if($value['source'] === '') {
continue;
}
}
if ($value['destination'] === '%NEXTCLOUD_MOUNT%') {
$value['destination'] = $this->configurationManager->GetNextcloudMount();
if($value['destination'] === '') {
continue;
if ($value['destination'] === '%NEXTCLOUD_MOUNT%') {
$value['destination'] = $this->configurationManager->GetNextcloudMount();
if($value['destination'] === '') {
continue;
}
}
$volumes->AddVolume(
new ContainerVolume(
$value['source'],
$value['destination'],
$value['writeable']
)
);
}
$volumes->AddVolume(
new ContainerVolume(
$value['source'],
$value['destination'],
$value['writeable']
)
);
}

$dependsOn = [];
foreach ($entry['depends_on'] as $value) {
if ($value === 'nextcloud-aio-clamav') {
if (!$this->configurationManager->isClamavEnabled()) {
continue;
}
} elseif ($value === 'nextcloud-aio-onlyoffice') {
if (!$this->configurationManager->isOnlyofficeEnabled()) {
continue;
}
} elseif ($value === 'nextcloud-aio-collabora') {
if (!$this->configurationManager->isCollaboraEnabled()) {
continue;
}
} elseif ($value === 'nextcloud-aio-talk') {
if (!$this->configurationManager->isTalkEnabled()) {
continue;
}
} elseif ($value === 'nextcloud-aio-imaginary') {
if (!$this->configurationManager->isImaginaryEnabled()) {
continue;
}
} elseif ($value === 'nextcloud-aio-fulltextsearch') {
if (!$this->configurationManager->isFulltextsearchEnabled()) {
continue;
if (isset($entry['depends_on'])) {
foreach ($entry['depends_on'] as $value) {
if ($value === 'nextcloud-aio-clamav') {
if (!$this->configurationManager->isClamavEnabled()) {
continue;
}
} elseif ($value === 'nextcloud-aio-onlyoffice') {
if (!$this->configurationManager->isOnlyofficeEnabled()) {
continue;
}
} elseif ($value === 'nextcloud-aio-collabora') {
if (!$this->configurationManager->isCollaboraEnabled()) {
continue;
}
} elseif ($value === 'nextcloud-aio-talk') {
if (!$this->configurationManager->isTalkEnabled()) {
continue;
}
} elseif ($value === 'nextcloud-aio-imaginary') {
if (!$this->configurationManager->isImaginaryEnabled()) {
continue;
}
} elseif ($value === 'nextcloud-aio-fulltextsearch') {
if (!$this->configurationManager->isFulltextsearchEnabled()) {
continue;
}
}
$dependsOn[] = $value;
}
$dependsOn[] = $value;
}

$variables = new ContainerEnvironmentVariables();
foreach ($entry['environment'] as $value) {
$variables->AddVariable($value);
if (isset($entry['environment'])) {
foreach ($entry['environment'] as $value) {
$variables->AddVariable($value);
}
}

$displayName = '';
if (isset($entry['display_name'])) {
$displayName = $entry['display_name'];
}

$restartPolicy = '';
if (isset($entry['restart'])) {
$restartPolicy = $entry['restart'];
}

$maxShutdownTime = 10;
if (isset($entry['stop_grace_period'])) {
$maxShutdownTime = $entry['stop_grace_period'];
}

$internalPort = '';
if (isset($entry['internal_port'])) {
$internalPort = $entry['internal_port'];
}

$secrets = [];
if (isset($entry['secrets'])) {
$secrets = $entry['secrets'];
}

$containers[] = new Container(
$entry['container_name'],
$entry['display_name'],
$displayName,
$entry['image'],
$entry['restart'],
$entry['stop_grace_period'],
$restartPolicy,
$maxShutdownTime,
$ports,
$entry['internal_port'],
$internalPort,
$volumes,
$variables,
$dependsOn,
$entry['secrets'],
$secrets,
$this->container->get(DockerActionManager::class)
);
}
Expand Down

0 comments on commit d4893be

Please sign in to comment.