From c96daad12c29e225071e5acc5eed9d5069a2a3b9 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Fri, 31 May 2024 10:34:07 +0200 Subject: [PATCH] refactor: Improve Docker Compose parsing for services --- bootstrap/helpers/shared.php | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php index 327c83d23..82badc90e 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -657,21 +657,10 @@ function getTopLevelNetworks(Service|Application $resource) } } -function parseDockerComposeForServices(Service $resource) { - if (!data_get($resource,'docker_compose_raw')) { - return collect([]); - } - try { - $yaml = Yaml::parse(data_get($resource,'docker_compose_raw')); - } catch (\Exception $e) { - throw new \Exception($e->getMessage()); - } -} function parseDockerComposeFile(Service|Application $resource, bool $isNew = false, int $pull_request_id = 0, bool $is_pr = false) { ray()->clearAll(); if ($resource->getMorphClass() === 'App\Models\Service') { - // return parseDockerComposeForServices($resource); if ($resource->docker_compose_raw) { try { $yaml = Yaml::parse($resource->docker_compose_raw); @@ -700,8 +689,8 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal } $tempTopLevelVolumes->put($volumeName, $volume); } + $topLevelVolumes = collect($tempTopLevelVolumes); } - $topLevelVolumes = collect($tempTopLevelVolumes); $services = collect($services)->map(function ($service, $serviceName) use ($topLevelVolumes, $topLevelNetworks, $definedNetwork, $isNew, $generatedServiceFQDNS, $resource, $allServices) { // Workarounds for beta users. if ($serviceName === 'registry') { @@ -1320,8 +1309,8 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal } $tempTopLevelVolumes->put($volumeName, $volume); } + $topLevelVolumes = collect($tempTopLevelVolumes); } - $topLevelVolumes = collect($tempTopLevelVolumes); $topLevelNetworks = collect(data_get($yaml, 'networks', [])); $services = data_get($yaml, 'services');