feat: Refactor shared.php to improve environment variable handling
This commit is contained in:
@@ -3219,10 +3219,31 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int
|
|||||||
|
|
||||||
// filter magic environments
|
// filter magic environments
|
||||||
$magicEnvironments = $environment->filter(function ($value, $key) {
|
$magicEnvironments = $environment->filter(function ($value, $key) {
|
||||||
|
$regex = '/\$\{(.*?)\}/';
|
||||||
|
preg_match_all($regex, $value, $matches);
|
||||||
|
if (count($matches[1]) > 0) {
|
||||||
|
foreach ($matches[1] as $match) {
|
||||||
|
if (str($match)->startsWith('SERVICE_') || str($match)->startsWith('SERVICE_')) {
|
||||||
|
return $match;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
$value = str(replaceVariables(str($value)));
|
$value = str(replaceVariables(str($value)));
|
||||||
|
|
||||||
return str($key)->startsWith('SERVICE_') || str($value)->startsWith('SERVICE_');
|
return str($key)->startsWith('SERVICE_') || str($value)->startsWith('SERVICE_');
|
||||||
});
|
});
|
||||||
|
foreach ($environment as $key => $value) {
|
||||||
|
$regex = '/\$\{(.*?)\}/';
|
||||||
|
preg_match_all($regex, $value, $matches);
|
||||||
|
if (count($matches[1]) > 0) {
|
||||||
|
foreach ($matches[1] as $match) {
|
||||||
|
if (str($match)->startsWith('SERVICE_') || str($match)->startsWith('SERVICE_')) {
|
||||||
|
$magicEnvironments->put($match, '$'.$match);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$magicEnvironments->forget($key);
|
||||||
|
}
|
||||||
|
}
|
||||||
$normalEnvironments = $environment->diffKeys($magicEnvironments);
|
$normalEnvironments = $environment->diffKeys($magicEnvironments);
|
||||||
if ($magicEnvironments->count() > 0) {
|
if ($magicEnvironments->count() > 0) {
|
||||||
foreach ($magicEnvironments as $key => $value) {
|
foreach ($magicEnvironments as $key => $value) {
|
||||||
|
Reference in New Issue
Block a user