fix(parser): improve FQDN generation and update environment variable handling

This commit is contained in:
Andras Bacsai
2025-06-24 13:28:52 +02:00
parent 8fc79022f3
commit e42c5baedd

View File

@@ -3060,14 +3060,20 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int
$port = null; $port = null;
} }
if ($isApplication) { if ($isApplication) {
$fqdn = $resource->fqdn;
if (blank($resource->fqdn)) {
$fqdn = generateFqdn($server, "$uuid"); $fqdn = generateFqdn($server, "$uuid");
}
} elseif ($isService) { } elseif ($isService) {
$fqdn = $savedService->fqdn;
if (blank($savedService->fqdn)) {
if ($fqdnFor) { if ($fqdnFor) {
$fqdn = generateFqdn($server, "$fqdnFor-$uuid"); $fqdn = generateFqdn($server, "$fqdnFor-$uuid");
} else { } else {
$fqdn = generateFqdn($server, "{$savedService->name}-$uuid"); $fqdn = generateFqdn($server, "{$savedService->name}-$uuid");
} }
} }
}
if ($value && get_class($value) === \Illuminate\Support\Stringable::class && $value->startsWith('/')) { if ($value && get_class($value) === \Illuminate\Support\Stringable::class && $value->startsWith('/')) {
$path = $value->value(); $path = $value->value();
@@ -3090,7 +3096,7 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int
} }
if (substr_count(str($key)->value(), '_') === 2) { if (substr_count(str($key)->value(), '_') === 2) {
$resource->environment_variables()->firstOrCreate([ $resource->environment_variables()->updateOrCreate([
'key' => $key->value(), 'key' => $key->value(),
'resourceable_type' => get_class($resource), 'resourceable_type' => get_class($resource),
'resourceable_id' => $resource->id, 'resourceable_id' => $resource->id,
@@ -3102,7 +3108,7 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int
} }
if (substr_count(str($key)->value(), '_') === 3) { if (substr_count(str($key)->value(), '_') === 3) {
$newKey = str($key)->beforeLast('_'); $newKey = str($key)->beforeLast('_');
$resource->environment_variables()->firstOrCreate([ $resource->environment_variables()->updateOrCreate([
'key' => $newKey->value(), 'key' => $newKey->value(),
'resourceable_type' => get_class($resource), 'resourceable_type' => get_class($resource),
'resourceable_id' => $resource->id, 'resourceable_id' => $resource->id,