From 31e02a154c93a8579df1e7e1185cb58cd764eb18 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 7 Jun 2024 17:06:27 +0200 Subject: [PATCH] refactor: Improve handling of Docker volumes in parseDockerComposeFile function --- bootstrap/helpers/shared.php | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php index 15ed4452d..3fcc335a0 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -911,7 +911,7 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal } else if ($type->value() === 'volume') { if ($topLevelVolumes->has($source->value())) { $v = $topLevelVolumes->get($source->value()); - if (data_get($v, 'driver_opts')) { + if (data_get($v, 'driver_opts.type') === 'cifs') { return $volume; } } @@ -1370,13 +1370,14 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal $volume = str("$name:$mount"); if ($topLevelVolumes->has($name)) { $v = $topLevelVolumes->get($name); - if (data_get($v, 'driver_opts')) { + if (data_get($v, 'driver_opts.type') === 'cifs') { // Do nothing + } else { + if (is_null(data_get($v, 'name'))) { + data_set($v, 'name', $name); + data_set($topLevelVolumes, $name, $v); + } } - if (is_null(data_get($v, 'name'))) { - data_set($v, 'name', $name); - } - data_set($topLevelVolumes, $name, $v); } else { $topLevelVolumes->put($name, [ 'name' => $name, @@ -1385,13 +1386,13 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal } else { if ($topLevelVolumes->has($name->value())) { $v = $topLevelVolumes->get($name->value()); - if (data_get($v, 'driver_opts')) { + if (data_get($v, 'driver_opts.type') === 'cifs') { // Do nothing + } else { + if (is_null(data_get($v, 'name'))) { + data_set($topLevelVolumes, $name->value(), $v); + } } - if (is_null(data_get($v, 'name'))) { - data_set($v, 'name', $name->value()); - } - data_set($topLevelVolumes, $name->value(), $v); } else { $topLevelVolumes->put($name->value(), [ 'name' => $name->value(), @@ -1442,13 +1443,14 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal if (!str($source)->startsWith('/')) { if ($topLevelVolumes->has($source)) { $v = $topLevelVolumes->get($source); - if (data_get($v, 'driver_opts')) { + if (data_get($v, 'driver_opts.type') === 'cifs') { // Do nothing + } else { + if (is_null(data_get($v, 'name'))) { + data_set($v, 'name', $source); + data_set($topLevelVolumes, $source, $v); + } } - if (is_null(data_get($v, 'name'))) { - data_set($v, 'name', $source); - } - data_set($topLevelVolumes, $source, $v); } else { $topLevelVolumes->put($source, [ 'name' => $source,