mirror of
https://github.com/tiennm99/coolify.git
synced 2026-10-13 22:15:35 +00:00
fix(parsers): resolve shared variables in compose environment
Extract shared variable resolution logic into a reusable helper function
`resolveSharedEnvironmentVariables()` and apply it in applicationParser and
serviceParser to ensure patterns like {{environment.VAR}}, {{project.VAR}},
and {{team.VAR}} are properly resolved in the compose environment section.
Without this, unresolved {{...}} strings would take precedence over resolved
values from the .env file (env_file:) in docker-compose configurations.
This commit is contained in:
1 parent
709e5e882e
commit
7cfc6746c7
4 files changed
+189
-31
No files matched your search
@@ -1294,6 +1294,13 @@ function applicationParser(Application $resource, int $pull_request_id = 0, ?int
|
||||
// Otherwise keep empty string as-is
|
||||
}
|
||||
|
||||
// Resolve shared variable patterns like {{environment.VAR}}, {{project.VAR}}, {{team.VAR}}
|
||||
// Without this, literal {{...}} strings end up in the compose environment: section,
|
||||
// which takes precedence over the resolved values in the .env file (env_file:)
|
||||
if (is_string($value) && str_contains($value, '{{')) {
|
||||
$value = resolveSharedEnvironmentVariables($value, $resource);
|
||||
}
|
||||
|
||||
return $value;
|
||||
});
|
||||
}
|
||||
@@ -2558,6 +2565,13 @@ function serviceParser(Service $resource): Collection
|
||||
// Otherwise keep empty string as-is
|
||||
}
|
||||
|
||||
// Resolve shared variable patterns like {{environment.VAR}}, {{project.VAR}}, {{team.VAR}}
|
||||
// Without this, literal {{...}} strings end up in the compose environment: section,
|
||||
// which takes precedence over the resolved values in the .env file (env_file:)
|
||||
if (is_string($value) && str_contains($value, '{{')) {
|
||||
$value = resolveSharedEnvironmentVariables($value, $resource);
|
||||
}
|
||||
|
||||
return $value;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user