@@ -3206,6 +3206,7 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int
3206
3206
}
3207
3207
}
3208
3208
// convert environment variables to one format
3209
+ ray ($ environment );
3209
3210
$ environment = convertComposeEnvironmentToArray ($ environment );
3210
3211
3211
3212
// Add Coolify defined environments
@@ -3639,37 +3640,22 @@ function add_coolify_default_environment_variables(StandaloneRedis|StandalonePos
3639
3640
$ where_to_add ->push ("COOLIFY_PROJECT_NAME= {$ resource ->project ()->name }" );
3640
3641
}
3641
3642
}
3642
- ray ($ where_to_add );
3643
3643
}
3644
3644
3645
3645
function convertComposeEnvironmentToArray ($ environment )
3646
3646
{
3647
3647
$ convertedServiceVariables = collect ([]);
3648
- foreach ($ environment as $ variableName => $ variableValue ) {
3649
- if (is_array ($ variableValue )) {
3650
- $ key = str (collect ($ variableValue )->keys ()->first ());
3651
- $ value = str (collect ($ variableValue )->values ()->first ());
3652
- } elseif (is_string ($ variableValue )) {
3653
- if (str ($ variableValue )->contains ('= ' )) {
3654
- $ key = str ($ variableValue )->before ('= ' );
3655
- $ value = str ($ variableValue )->after ('= ' );
3656
- } else {
3657
- if (is_numeric ($ variableName )) {
3658
- $ key = str ($ variableValue );
3659
- $ value = null ;
3660
- } else {
3661
- $ key = str ($ variableName );
3662
- if ($ variableValue ) {
3663
- $ value = str ($ variableValue );
3664
- } else {
3665
- $ value = null ;
3666
- }
3667
- }
3648
+ if (isAssociativeArray ($ environment )) {
3649
+ $ convertedServiceVariables = $ environment ;
3650
+ } else {
3651
+ foreach ($ environment as $ value ) {
3652
+ $ parts = explode ('= ' , $ value , 2 );
3653
+ $ key = $ parts [0 ];
3654
+ $ realValue = $ parts [1 ] ?? '' ;
3655
+ if ($ key ) {
3656
+ $ convertedServiceVariables ->put ($ key , $ realValue );
3668
3657
}
3669
3658
}
3670
- if ($ key ) {
3671
- $ convertedServiceVariables ->put ($ key ->value (), $ value ?->value() ?? null );
3672
- }
3673
3659
}
3674
3660
3675
3661
return $ convertedServiceVariables ;
0 commit comments