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,13 +750,14 @@ 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);
}
}
// 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()) {
$envs->push("PORT={$ports[0]}");
@ -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,9 +1525,11 @@ 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");
}
}
foreach ($this->application->nixpacks_environment_variables as $env) {
if ($env->version === '4.0.0-beta.239') {
$real_value = $env->real_value;
@ -1535,9 +1538,11 @@ 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");
}
}
} else {
foreach ($this->application->runtime_environment_variables_preview as $env) {
if ($env->version === '4.0.0-beta.239') {
@ -1547,9 +1552,11 @@ 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");
}
}
foreach ($this->application->nixpacks_environment_variables_preview as $env) {
if ($env->version === '4.0.0-beta.239') {
$real_value = $env->real_value;
@ -1558,10 +1565,12 @@ 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");
}
}
}
// Add PORT if not exists, use the first port as default
if ($environment_variables->filter(fn ($env) => Str::of($env)->startsWith('PORT'))->isEmpty()) {
$environment_variables->push("PORT={$ports[0]}");
@ -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()
{