Skip to content

Commit a9670bd

Browse files
committed
refactor: Remove commented out code and improve environment variable handling in newParser function
1 parent 02165c2 commit a9670bd

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

bootstrap/helpers/shared.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2928,7 +2928,7 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int
29282928
}
29292929

29302930
$parsedServices = collect([]);
2931-
ray()->clearAll();
2931+
// ray()->clearAll();
29322932

29332933
$allMagicEnvironments = collect([]);
29342934
foreach ($services as $serviceName => $service) {
@@ -3493,6 +3493,8 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int
34933493
'is_build_time' => false,
34943494
'is_preview' => false,
34953495
]);
3496+
// Add the variable to the environment so it will be shown in the deployable compose file
3497+
$environment[$parsedKeyValue->value()] = $resource->environment_variables()->where('key', $parsedKeyValue)->where($nameOfId, $resource->id)->first()->value;
34963498

34973499
continue;
34983500
}
@@ -3586,10 +3588,14 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int
35863588
if ($environment->count() > 0) {
35873589
$environment = $environment->filter(function ($value, $key) {
35883590
return ! str($key)->startsWith('SERVICE_FQDN_');
3589-
})->map(function ($value, $key) {
3591+
})->map(function ($value, $key) use ($resource) {
35903592
// if value is empty, set it to null so if you set the environment variable in the .env file (Coolify's UI), it will used
35913593
if (str($value)->isEmpty()) {
3592-
$value = null;
3594+
if ($resource->environment_variables()->where('key', $key)->exists()) {
3595+
$value = $resource->environment_variables()->where('key', $key)->first()->value;
3596+
} else {
3597+
$value = null;
3598+
}
35933599
}
35943600

35953601
return $value;

0 commit comments

Comments
 (0)