Service deployment

This commit is contained in:
2025-03-31 15:40:35 +00:00
parent a62565d0ad
commit 7ad259bc38
3 changed files with 47 additions and 1 deletions

View File

@@ -31,5 +31,7 @@ class CreateService
$defaultPassword = Str::random(16);
dispatch(new DeployService($service, $defaultPassword));
return ['defaultPassword' => $defaultPassword, 'service' => $service];
}
}

View 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);
}
}

View File

@@ -103,7 +103,7 @@ class ServerController extends Controller
$server = $organisation->servers()->findOrFail($request->route('server'));
return inertia('servers/Show', [
'server' => $server,
'server' => $server->load('services'),
]);
}
}