Server creation: Only get node_id from allocation if it is missing (#1598)

This commit is contained in:
Boy132 2025-08-12 21:02:49 +02:00 committed by GitHub
parent 46934d7a85
commit 795cad43b9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -56,8 +56,8 @@ class ServerCreationService
$egg = Egg::query()->findOrFail($data['egg_id']);
// Fill missing fields from egg
$data['image'] = $data['image'] ?? collect($egg->docker_images)->first();
$data['startup'] = $data['startup'] ?? $egg->startup;
$data['image'] ??= collect($egg->docker_images)->first();
$data['startup'] ??= $egg->startup;
// If a deployment object has been passed we need to get the allocation and node that the server should use.
if ($deployment) {
@ -87,7 +87,7 @@ class ServerCreationService
$data['node_id'] = $nodes->first();
}
} else {
$data['node_id'] = Allocation::find($data['allocation_id'])?->node_id;
$data['node_id'] ??= Allocation::find($data['allocation_id'])?->node_id;
}
Assert::false(empty($data['node_id']), 'Expected a non-empty node_id in server creation data.');