Service deployment
This commit is contained in:
@@ -31,5 +31,7 @@ class CreateService
|
|||||||
$defaultPassword = Str::random(16);
|
$defaultPassword = Str::random(16);
|
||||||
|
|
||||||
dispatch(new DeployService($service, $defaultPassword));
|
dispatch(new DeployService($service, $defaultPassword));
|
||||||
|
|
||||||
|
return ['defaultPassword' => $defaultPassword, 'service' => $service];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
44
app/Console/Commands/CreateServiceCommand.php
Normal file
44
app/Console/Commands/CreateServiceCommand.php
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Actions\Services\CreateService;
|
||||||
|
use App\Enums\ServiceCategory;
|
||||||
|
use App\Enums\ServiceType;
|
||||||
|
use App\Models\Server;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
|
class CreateServiceCommand extends Command
|
||||||
|
{
|
||||||
|
protected $signature = 'service:create';
|
||||||
|
protected $description = 'Create a service';
|
||||||
|
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
$serverId = $this->components->ask('Enter the server ID');
|
||||||
|
$server = Server::find($serverId);
|
||||||
|
|
||||||
|
if (!$server) {
|
||||||
|
$this->components->error('Server not found');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$serviceType = $this->components->choice('select the service you want to install', [
|
||||||
|
'postgres-17'
|
||||||
|
]);
|
||||||
|
|
||||||
|
$serviceName = $this->components->ask('Enter the service name');
|
||||||
|
|
||||||
|
$service = app(CreateService::class)->execute(
|
||||||
|
server: $server,
|
||||||
|
name: $serviceName,
|
||||||
|
category: ServiceCategory::DATABASE,
|
||||||
|
type: ServiceType::POSTGRES,
|
||||||
|
version: '17',
|
||||||
|
driverName: $serviceType,
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->components->info('Service created successfully');
|
||||||
|
dump($service);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -103,7 +103,7 @@ class ServerController extends Controller
|
|||||||
$server = $organisation->servers()->findOrFail($request->route('server'));
|
$server = $organisation->servers()->findOrFail($request->route('server'));
|
||||||
|
|
||||||
return inertia('servers/Show', [
|
return inertia('servers/Show', [
|
||||||
'server' => $server,
|
'server' => $server->load('services'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user