mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-19 22:14:45 +02:00
Fill startup & image from egg if missing in request (#384)
This commit is contained in:
parent
0da184c56e
commit
6916b89638
@ -28,8 +28,8 @@ class StoreServerRequest extends ApplicationApiRequest
|
||||
'description' => array_merge(['nullable'], $rules['description']),
|
||||
'user' => $rules['owner_id'],
|
||||
'egg' => $rules['egg_id'],
|
||||
'docker_image' => $rules['image'],
|
||||
'startup' => $rules['startup'],
|
||||
'docker_image' => 'sometimes|string',
|
||||
'startup' => 'sometimes|string',
|
||||
'environment' => 'present|array',
|
||||
'skip_scripts' => 'sometimes|boolean',
|
||||
'oom_killer' => 'sometimes|boolean',
|
||||
|
@ -20,10 +20,10 @@ class UpdateServerStartupRequest extends ApplicationApiRequest
|
||||
$data = Server::getRulesForUpdate($this->parameter('server', Server::class));
|
||||
|
||||
return [
|
||||
'startup' => $data['startup'],
|
||||
'startup' => 'sometimes|string',
|
||||
'environment' => 'present|array',
|
||||
'egg' => $data['egg_id'],
|
||||
'image' => $data['image'],
|
||||
'image' => 'sometimes|string',
|
||||
'skip_scripts' => 'present|boolean',
|
||||
];
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ use App\Repositories\Daemon\DaemonServerRepository;
|
||||
use App\Services\Deployment\FindViableNodesService;
|
||||
use App\Services\Deployment\AllocationSelectionService;
|
||||
use App\Exceptions\Http\Connection\DaemonConnectionException;
|
||||
use App\Models\Egg;
|
||||
|
||||
class ServerCreationService
|
||||
{
|
||||
@ -50,6 +51,13 @@ class ServerCreationService
|
||||
$data['oom_killer'] = !$data['oom_disabled'];
|
||||
}
|
||||
|
||||
/** @var Egg $egg */
|
||||
$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;
|
||||
|
||||
// If a deployment object has been passed we need to get the allocation
|
||||
// that the server should use, and assign the node from that allocation.
|
||||
if ($deployment instanceof DeploymentObject) {
|
||||
|
@ -76,6 +76,10 @@ class StartupModificationService
|
||||
$server = $server->forceFill([
|
||||
'egg_id' => $egg->id,
|
||||
]);
|
||||
|
||||
// Fill missing fields from egg
|
||||
$data['docker_image'] = $data['docker_image'] ?? collect($egg->docker_images)->first();
|
||||
$data['startup'] = $data['startup'] ?? $egg->startup;
|
||||
}
|
||||
|
||||
$server->fill([
|
||||
|
Loading…
x
Reference in New Issue
Block a user