Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge containers.json and make sure they depend on the apache container #3425

Merged
merged 1 commit into from
Sep 27, 2023
Merged
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
51 changes: 19 additions & 32 deletions php/src/ContainerDefinitionFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,20 @@ public function GetContainerById(string $id): Container
/**
* @return array
*/
private function GetDefinition(bool $latest): array
private function GetDefinition(): array
{
$data = json_decode(file_get_contents(__DIR__ . '/../containers.json'), true);

$additionalContainerNames = [];
foreach ($this->configurationManager->GetEnabledCommunityContainers() as $communityContainer) {
if ($communityContainer !== '') {
$path = DataConst::GetCommunityContainersDirectory() . $communityContainer . '/' . $communityContainer . '.json';
$additionalData = json_decode(file_get_contents($path), true);
$data = array_merge_recursive($data, $additionalData);
$additionalContainerNames[] = $additionalData['aio_services_v1'][]['container_name'];
}
}

$containers = [];
foreach ($data['aio_services_v1'] as $entry) {
if ($entry['container_name'] === 'nextcloud-aio-clamav') {
Expand Down Expand Up @@ -154,7 +164,13 @@ private function GetDefinition(bool $latest): array

$dependsOn = [];
if (isset($entry['depends_on'])) {
foreach ($entry['depends_on'] as $value) {
$valueDependsOn = $entry['depends_on'];
if ($entry['container_name'] === 'nextcloud-aio-apache') {
foreach ($additionalContainerNames as $containerName) {
$valueDependsOn[] = $containerName;
}
}
foreach ($valueDependsOn as $value) {
if ($value === 'nextcloud-aio-clamav') {
if (!$this->configurationManager->isClamavEnabled()) {
continue;
Expand Down Expand Up @@ -305,35 +321,6 @@ private function GetDefinition(bool $latest): array

public function FetchDefinition(): array
{
if (!file_exists(DataConst::GetDataDirectory() . '/containers.json')) {
$containers = $this->GetDefinition(true);
} else {
$containers = $this->GetDefinition(false);
}

$borgBackupMode = $this->configurationManager->GetBorgBackupMode();
$fetchLatest = false;

foreach ($containers as $container) {

if ($container->GetIdentifier() === 'nextcloud-aio-borgbackup') {
if ($container->GetRunningState() === RunningState::class) {
if ($borgBackupMode !== 'backup' && $borgBackupMode !== 'restore') {
$fetchLatest = true;
}
} else {
$fetchLatest = true;
}

} elseif ($container->GetIdentifier() === 'nextcloud-aio-watchtower' && $container->GetRunningState() === RunningState::class) {
return $containers;
}
}

if ($fetchLatest === true) {
$containers = $this->GetDefinition(true);
}

return $containers;
return $this->GetDefinition();
}
}