From f626d964c5c933bd50e3b8d79eb78f3ddebb1445 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 25 Apr 2024 13:25:35 +0200 Subject: [PATCH] Fix environment variable generation in ApplicationDeploymentJob.php --- app/Jobs/ApplicationDeploymentJob.php | 32 ++++++++++++++++++--------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index 52afdd47e..db64b6542 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -750,12 +750,13 @@ private function save_environment_variables() if ($env->version === '4.0.0-beta.239') { $real_value = $env->real_value; } else { - $real_value = escapeEnvVariables($env->real_value); + if ($env->is_literal) { + $real_value = '\'' . $real_value . '\''; + } else { + $real_value = escapeEnvVariables($env->real_value); + } + $envs->push($env->key . '=' . $real_value); } - if ($env->is_literal) { - $real_value = '\'' . $real_value . '\''; - } - $envs->push($env->key . '=' . $real_value); } // Add PORT if not exists, use the first port as default if ($this->application->environment_variables->filter(fn ($env) => Str::of($env)->startsWith('PORT'))->isEmpty()) { @@ -1506,7 +1507,7 @@ private function generate_local_persistent_volumes_only_volume_names() return $local_persistent_volumes_names; } - private function generate_environment_variables($ports) + /*private function generate_environment_variables($ports) { $environment_variables = collect(); if ($this->pull_request_id === 0) { @@ -1524,8 +1525,10 @@ private function generate_environment_variables($ports) } if ($env->is_literal) { $real_value = escapeDollarSign($real_value); + $environment_variables->push("$env->key='$real_value'"); + } else { + $environment_variables->push("$env->key=$real_value"); } - $environment_variables->push("$env->key=$real_value"); } foreach ($this->application->nixpacks_environment_variables as $env) { if ($env->version === '4.0.0-beta.239') { @@ -1535,8 +1538,10 @@ private function generate_environment_variables($ports) } if ($env->is_literal) { $real_value = escapeDollarSign($real_value); + $environment_variables->push("$env->key='$real_value'"); + } else { + $environment_variables->push("$env->key=$real_value"); } - $environment_variables->push("$env->key=$real_value"); } } else { foreach ($this->application->runtime_environment_variables_preview as $env) { @@ -1547,8 +1552,10 @@ private function generate_environment_variables($ports) } if ($env->is_literal) { $real_value = escapeDollarSign($real_value); + $environment_variables->push("$env->key='$real_value'"); + } else { + $environment_variables->push("$env->key=$real_value"); } - $environment_variables->push("$env->key=$real_value"); } foreach ($this->application->nixpacks_environment_variables_preview as $env) { if ($env->version === '4.0.0-beta.239') { @@ -1558,8 +1565,10 @@ private function generate_environment_variables($ports) } if ($env->is_literal) { $real_value = escapeDollarSign($real_value); + $environment_variables->push("$env->key='$real_value'"); + } else { + $environment_variables->push("$env->key=$real_value"); } - $environment_variables->push("$env->key=$real_value"); } } // Add PORT if not exists, use the first port as default @@ -1577,8 +1586,9 @@ private function generate_environment_variables($ports) $environment_variables->push("SOURCE_COMMIT=unknown"); } } + ray($environment_variables->all()); return $environment_variables->all(); - } + }*/ private function generate_healthcheck_commands() {