mirror of
https://github.com/cupcakearmy/coolify.git
synced 2024-10-22 08:04:19 +02:00
fix: Convert environment variables to one format in shared.php
This commit is contained in:
parent
59383d3678
commit
25e2b812cb
@ -3206,6 +3206,7 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// convert environment variables to one format
|
// convert environment variables to one format
|
||||||
|
ray($environment);
|
||||||
$environment = convertComposeEnvironmentToArray($environment);
|
$environment = convertComposeEnvironmentToArray($environment);
|
||||||
|
|
||||||
// Add Coolify defined environments
|
// Add Coolify defined environments
|
||||||
@ -3639,37 +3640,22 @@ function add_coolify_default_environment_variables(StandaloneRedis|StandalonePos
|
|||||||
$where_to_add->push("COOLIFY_PROJECT_NAME={$resource->project()->name}");
|
$where_to_add->push("COOLIFY_PROJECT_NAME={$resource->project()->name}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ray($where_to_add);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function convertComposeEnvironmentToArray($environment)
|
function convertComposeEnvironmentToArray($environment)
|
||||||
{
|
{
|
||||||
$convertedServiceVariables = collect([]);
|
$convertedServiceVariables = collect([]);
|
||||||
foreach ($environment as $variableName => $variableValue) {
|
if (isAssociativeArray($environment)) {
|
||||||
if (is_array($variableValue)) {
|
$convertedServiceVariables = $environment;
|
||||||
$key = str(collect($variableValue)->keys()->first());
|
} else {
|
||||||
$value = str(collect($variableValue)->values()->first());
|
foreach ($environment as $value) {
|
||||||
} elseif (is_string($variableValue)) {
|
$parts = explode('=', $value, 2);
|
||||||
if (str($variableValue)->contains('=')) {
|
$key = $parts[0];
|
||||||
$key = str($variableValue)->before('=');
|
$realValue = $parts[1] ?? '';
|
||||||
$value = str($variableValue)->after('=');
|
if ($key) {
|
||||||
} else {
|
$convertedServiceVariables->put($key, $realValue);
|
||||||
if (is_numeric($variableName)) {
|
|
||||||
$key = str($variableValue);
|
|
||||||
$value = null;
|
|
||||||
} else {
|
|
||||||
$key = str($variableName);
|
|
||||||
if ($variableValue) {
|
|
||||||
$value = str($variableValue);
|
|
||||||
} else {
|
|
||||||
$value = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($key) {
|
|
||||||
$convertedServiceVariables->put($key->value(), $value?->value() ?? null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $convertedServiceVariables;
|
return $convertedServiceVariables;
|
||||||
|
Loading…
Reference in New Issue
Block a user