From afbdd2eb065c0679de2ab0367af493edeeb57857 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 24 Sep 2024 18:21:31 +0200 Subject: [PATCH] fix: parser --- bootstrap/helpers/shared.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php index 072f80a0a..82cfec9e3 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -3484,6 +3484,16 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int $value = $value->after('?'); } if ($originalValue->value() === $value->value()) { + // This means the variable does not have a default value, so it needs to be created in Coolify + $parsedKeyValue = replaceVariables($value); + $resource->environment_variables()->where('key', $parsedKeyValue)->where($nameOfId, $resource->id)->firstOrCreate([ + 'key' => $parsedKeyValue, + $nameOfId => $resource->id, + ], [ + 'is_build_time' => false, + 'is_preview' => false, + ]); + continue; } $resource->environment_variables()->where('key', $key)->where($nameOfId, $resource->id)->firstOrCreate([ @@ -3576,6 +3586,13 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int if ($environment->count() > 0) { $environment = $environment->filter(function ($value, $key) { return ! str($key)->startsWith('SERVICE_FQDN_'); + })->map(function ($value, $key) { + // 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 + if (str($value)->isEmpty()) { + $value = null; + } + + return $value; }); } $serviceLabels = $labels->merge($defaultLabels);