substitute volume variables in dockeractionmanager

Signed-off-by: Simon L <szaimen@e.mail.de>
This commit is contained in:
Simon L 2022-12-26 02:14:06 +01:00
parent 117c3de7c5
commit b5e40dbb94
2 changed files with 34 additions and 33 deletions

View file

@ -94,39 +94,6 @@ class ContainerDefinitionFetcher
$volumes = new ContainerVolumes(); $volumes = new ContainerVolumes();
foreach ($entry['volumes'] as $value) { foreach ($entry['volumes'] as $value) {
if($value['name'] === '%BORGBACKUP_HOST_LOCATION%') {
$value['name'] = $this->configurationManager->GetBorgBackupHostLocation();
if($value['name'] === '') {
continue;
}
}
if($value['name'] === '%NEXTCLOUD_MOUNT%') {
$value['name'] = $this->configurationManager->GetNextcloudMount();
if($value['name'] === '') {
continue;
}
} elseif ($value['name'] === '%NEXTCLOUD_DATADIR%') {
$value['name'] = $this->configurationManager->GetNextcloudDatadirMount();
if ($value['name'] === '') {
continue;
}
} elseif ($value['name'] === '%DOCKER_SOCKET_PATH%') {
$value['name'] = $this->configurationManager->GetDockerSocketPath();
if($value['name'] === '') {
continue;
}
} elseif ($value['name'] === '%NEXTCLOUD_TRUSTED_CACERTS_DIR%') {
$value['name'] = $this->configurationManager->GetTrustedCacertsDir();
if($value['name'] === '') {
continue;
}
}
if ($value['location'] === '%NEXTCLOUD_MOUNT%') {
$value['location'] = $this->configurationManager->GetNextcloudMount();
if($value['location'] === '') {
continue;
}
}
$volumes->AddVolume( $volumes->AddVolume(
new ContainerVolume( new ContainerVolume(
$value['name'], $value['name'],

View file

@ -205,6 +205,40 @@ class DockerActionManager
public function CreateContainer(Container $container) : void { public function CreateContainer(Container $container) : void {
$volumes = []; $volumes = [];
foreach($container->GetVolumes()->GetVolumes() as $volume) { foreach($container->GetVolumes()->GetVolumes() as $volume) {
if($volume->name === '%BORGBACKUP_HOST_LOCATION%') {
$volume->name = $this->configurationManager->GetBorgBackupHostLocation();
if($volume->name === '') {
continue;
}
}
if($volume->name === '%NEXTCLOUD_MOUNT%') {
$volume->name = $this->configurationManager->GetNextcloudMount();
if($volume->name === '') {
continue;
}
} elseif ($volume->name === '%NEXTCLOUD_DATADIR%') {
$volume->name = $this->configurationManager->GetNextcloudDatadirMount();
if ($volume->name === '') {
continue;
}
} elseif ($volume->name === '%DOCKER_SOCKET_PATH%') {
$volume->name = $this->configurationManager->GetDockerSocketPath();
if($volume->name === '') {
continue;
}
} elseif ($volume->name === '%NEXTCLOUD_TRUSTED_CACERTS_DIR%') {
$volume->name = $this->configurationManager->GetTrustedCacertsDir();
if($volume->name === '') {
continue;
}
}
if ($volume->mountPoint === '%NEXTCLOUD_MOUNT%') {
$volume->mountPoint = $this->configurationManager->GetNextcloudMount();
if($volume->mountPoint === '') {
continue;
}
}
$volumeEntry = $volume->name . ':' . $volume->mountPoint; $volumeEntry = $volume->name . ':' . $volume->mountPoint;
if($volume->isWritable) { if($volume->isWritable) {
$volumeEntry = $volumeEntry . ':' . 'rw'; $volumeEntry = $volumeEntry . ':' . 'rw';