fix: only add 'networks' key if 'network_mode' is absent

This commit is contained in:
Matt 2024-02-11 09:22:09 -06:00
parent 059748ad3b
commit e6ca8cd167

View File

@ -527,7 +527,10 @@ function getTopLevelNetworks(Service|Application $resource)
$definedNetwork = collect([$resource->uuid]); $definedNetwork = collect([$resource->uuid]);
$services = collect($services)->map(function ($service, $_) use ($topLevelNetworks, $definedNetwork) { $services = collect($services)->map(function ($service, $_) use ($topLevelNetworks, $definedNetwork) {
$serviceNetworks = collect(data_get($service, 'networks', [])); $serviceNetworks = collect(data_get($service, 'networks', []));
$hasNetworkMode = data_get($service, 'network_mode');
// Only add 'networks' key if 'network_mode' is absent
if (!$hasNetworkMode) {
// Collect/create/update networks // Collect/create/update networks
if ($serviceNetworks->count() > 0) { if ($serviceNetworks->count() > 0) {
foreach ($serviceNetworks as $networkName => $networkDetails) { foreach ($serviceNetworks as $networkName => $networkDetails) {
@ -551,6 +554,7 @@ function getTopLevelNetworks(Service|Application $resource)
]); ]);
} }
} }
}
return $service; return $service;
}); });