Fix environment variable generation in ApplicationDeploymentJob.php

This commit is contained in:
Andras Bacsai 2024-04-25 13:25:35 +02:00
parent b0e0b38549
commit f626d964c5

View File

@ -750,12 +750,13 @@ private function save_environment_variables()
if ($env->version === '4.0.0-beta.239') { if ($env->version === '4.0.0-beta.239') {
$real_value = $env->real_value; $real_value = $env->real_value;
} else { } 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 // 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()) { 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; return $local_persistent_volumes_names;
} }
private function generate_environment_variables($ports) /*private function generate_environment_variables($ports)
{ {
$environment_variables = collect(); $environment_variables = collect();
if ($this->pull_request_id === 0) { if ($this->pull_request_id === 0) {
@ -1524,8 +1525,10 @@ private function generate_environment_variables($ports)
} }
if ($env->is_literal) { if ($env->is_literal) {
$real_value = escapeDollarSign($real_value); $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) { foreach ($this->application->nixpacks_environment_variables as $env) {
if ($env->version === '4.0.0-beta.239') { if ($env->version === '4.0.0-beta.239') {
@ -1535,8 +1538,10 @@ private function generate_environment_variables($ports)
} }
if ($env->is_literal) { if ($env->is_literal) {
$real_value = escapeDollarSign($real_value); $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 { } else {
foreach ($this->application->runtime_environment_variables_preview as $env) { foreach ($this->application->runtime_environment_variables_preview as $env) {
@ -1547,8 +1552,10 @@ private function generate_environment_variables($ports)
} }
if ($env->is_literal) { if ($env->is_literal) {
$real_value = escapeDollarSign($real_value); $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) { foreach ($this->application->nixpacks_environment_variables_preview as $env) {
if ($env->version === '4.0.0-beta.239') { if ($env->version === '4.0.0-beta.239') {
@ -1558,8 +1565,10 @@ private function generate_environment_variables($ports)
} }
if ($env->is_literal) { if ($env->is_literal) {
$real_value = escapeDollarSign($real_value); $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 // 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"); $environment_variables->push("SOURCE_COMMIT=unknown");
} }
} }
ray($environment_variables->all());
return $environment_variables->all(); return $environment_variables->all();
} }*/
private function generate_healthcheck_commands() private function generate_healthcheck_commands()
{ {