allow to define nextcloud_exec_commands in containers definition

Signed-off-by: Simon L <szaimen@e.mail.de>
This commit is contained in:
Simon L 2023-05-01 18:37:33 +02:00
parent 3e04dd5c2e
commit e4de4dcb67
10 changed files with 77 additions and 17 deletions

View file

@ -235,6 +235,10 @@ class DockerActionManager
}
$envs = $container->GetEnvironmentVariables()->GetVariables();
// Special thing for the nextcloud container
if ($container->GetIdentifier() === 'nextcloud-aio-nextcloud') {
$envs[] = $this->GetAllNextcloudExecCommands();
}
foreach($envs as $key => $env) {
// TODO: This whole block below is a hack and needs to get reworked in order to support multiple substitutions per line by default for all envs
if (str_starts_with($env, 'extra_params=')) {
@ -533,6 +537,26 @@ class DockerActionManager
return array_unique($backupVolumesArrayFlat);
}
private function GetNextcloudExecCommands(string $id) : string
{
$container = $this->containerDefinitionFetcher->GetContainerById($id);
$nextcloudExecCommands = '';
foreach ($container->GetNextcloudExecCommands() as $execCommand) {
$nextcloudExecCommands .= $execCommand . PHP_EOL;
}
foreach ($container->GetDependsOn() as $dependency) {
$nextcloudExecCommands .= $this->GetNextcloudExecCommands($dependency);
}
return $nextcloudExecCommands;
}
private function GetAllNextcloudExecCommands() : string
{
$id = 'nextcloud-aio-apache';
return 'NEXTCLOUD_EXEC_COMMANDS=' . $this->GetNextcloudExecCommands($id);
}
private function GetRepoDigestsOfContainer(string $containerName) : ?array {
try {
$containerUrl = $this->BuildApiUrl(sprintf('containers/%s/json', $containerName));