mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 00:34:44 +02:00
Remove NodeCreationService
(#1092)
This commit is contained in:
parent
253abf65b1
commit
22d02c0df5
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Console\Commands\Node;
|
namespace App\Console\Commands\Node;
|
||||||
|
|
||||||
|
use App\Models\Node;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use App\Services\Nodes\NodeCreationService;
|
|
||||||
|
|
||||||
class MakeNodeCommand extends Command
|
class MakeNodeCommand extends Command
|
||||||
{
|
{
|
||||||
@ -30,14 +30,6 @@ class MakeNodeCommand extends Command
|
|||||||
|
|
||||||
protected $description = 'Creates a new node on the system via the CLI.';
|
protected $description = 'Creates a new node on the system via the CLI.';
|
||||||
|
|
||||||
/**
|
|
||||||
* MakeNodeCommand constructor.
|
|
||||||
*/
|
|
||||||
public function __construct(private NodeCreationService $creationService)
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle the command execution process.
|
* Handle the command execution process.
|
||||||
*
|
*
|
||||||
@ -69,7 +61,7 @@ class MakeNodeCommand extends Command
|
|||||||
$data['daemon_sftp_alias'] = $this->option('daemonSFTPAlias') ?? $this->ask(trans('commands.make_node.daemonSFTPAlias'), '');
|
$data['daemon_sftp_alias'] = $this->option('daemonSFTPAlias') ?? $this->ask(trans('commands.make_node.daemonSFTPAlias'), '');
|
||||||
$data['daemon_base'] = $this->option('daemonBase') ?? $this->ask(trans('commands.make_node.daemonBase'), '/var/lib/pelican/volumes');
|
$data['daemon_base'] = $this->option('daemonBase') ?? $this->ask(trans('commands.make_node.daemonBase'), '/var/lib/pelican/volumes');
|
||||||
|
|
||||||
$node = $this->creationService->handle($data);
|
$node = Node::create($data);
|
||||||
$this->line(trans('commands.make_node.success', ['name' => $data['name'], 'id' => $node->id]));
|
$this->line(trans('commands.make_node.success', ['name' => $data['name'], 'id' => $node->id]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ use App\Models\Node;
|
|||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Spatie\QueryBuilder\QueryBuilder;
|
use Spatie\QueryBuilder\QueryBuilder;
|
||||||
use App\Services\Nodes\NodeUpdateService;
|
use App\Services\Nodes\NodeUpdateService;
|
||||||
use App\Services\Nodes\NodeCreationService;
|
|
||||||
use App\Services\Nodes\NodeDeletionService;
|
use App\Services\Nodes\NodeDeletionService;
|
||||||
use App\Transformers\Api\Application\NodeTransformer;
|
use App\Transformers\Api\Application\NodeTransformer;
|
||||||
use App\Http\Requests\Api\Application\Nodes\GetNodeRequest;
|
use App\Http\Requests\Api\Application\Nodes\GetNodeRequest;
|
||||||
@ -24,7 +23,6 @@ class NodeController extends ApplicationApiController
|
|||||||
* NodeController constructor.
|
* NodeController constructor.
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private NodeCreationService $creationService,
|
|
||||||
private NodeDeletionService $deletionService,
|
private NodeDeletionService $deletionService,
|
||||||
private NodeUpdateService $updateService
|
private NodeUpdateService $updateService
|
||||||
) {
|
) {
|
||||||
@ -74,7 +72,7 @@ class NodeController extends ApplicationApiController
|
|||||||
*/
|
*/
|
||||||
public function store(StoreNodeRequest $request): JsonResponse
|
public function store(StoreNodeRequest $request): JsonResponse
|
||||||
{
|
{
|
||||||
$node = $this->creationService->handle($request->validated());
|
$node = Node::create($request->validated());
|
||||||
|
|
||||||
return $this->fractal->item($node)
|
return $this->fractal->item($node)
|
||||||
->transformWith($this->getTransformer(NodeTransformer::class))
|
->transformWith($this->getTransformer(NodeTransformer::class))
|
||||||
|
@ -1,28 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Services\Nodes;
|
|
||||||
|
|
||||||
use Ramsey\Uuid\Uuid;
|
|
||||||
use Illuminate\Support\Str;
|
|
||||||
use App\Models\Node;
|
|
||||||
|
|
||||||
class NodeCreationService
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Create a new node on the panel.
|
|
||||||
*
|
|
||||||
* @todo remove this class
|
|
||||||
*
|
|
||||||
* @param array<string, mixed> $data
|
|
||||||
*
|
|
||||||
* @throws \App\Exceptions\Model\DataValidationException
|
|
||||||
*/
|
|
||||||
public function handle(array $data): Node
|
|
||||||
{
|
|
||||||
$data['uuid'] = Uuid::uuid4()->toString();
|
|
||||||
$data['daemon_token'] = Str::random(Node::DAEMON_TOKEN_LENGTH);
|
|
||||||
$data['daemon_token_id'] = Str::random(Node::DAEMON_TOKEN_ID_LENGTH);
|
|
||||||
|
|
||||||
return Node::query()->create($data);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user