refactor: Improve handling of Docker volumes in parseDockerComposeFile function

This commit is contained in:
Andras Bacsai 2024-06-07 17:06:27 +02:00
parent 023ee5db99
commit 31e02a154c

View File

@ -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,