Skip to content

Commit

Permalink
refactor: Improve Docker Compose parsing for services
Browse files Browse the repository at this point in the history
  • Loading branch information
andrasbacsai committed May 31, 2024
1 parent 9cc3be1 commit c96daad
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions bootstrap/helpers/shared.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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') {
Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit c96daad

Please sign in to comment.