mirror of
https://github.com/tiennm99/coolify.git
synced 2026-04-17 17:21:04 +00:00
feat: enhance prerequisite validation to return detailed results
This commit is contained in:
@@ -11,17 +11,30 @@ class ValidatePrerequisites
|
||||
|
||||
public string $jobQueue = 'high';
|
||||
|
||||
public function handle(Server $server): bool
|
||||
/**
|
||||
* Validate that required commands are available on the server.
|
||||
*
|
||||
* @return array{success: bool, missing: array<string>, found: array<string>}
|
||||
*/
|
||||
public function handle(Server $server): array
|
||||
{
|
||||
$requiredCommands = ['git', 'curl', 'jq'];
|
||||
$missing = [];
|
||||
$found = [];
|
||||
|
||||
foreach ($requiredCommands as $cmd) {
|
||||
$found = instant_remote_process(["command -v {$cmd}"], $server, false);
|
||||
if (! $found) {
|
||||
return false;
|
||||
$result = instant_remote_process(["command -v {$cmd}"], $server, false);
|
||||
if (! $result) {
|
||||
$missing[] = $cmd;
|
||||
} else {
|
||||
$found[] = $cmd;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return [
|
||||
'success' => empty($missing),
|
||||
'missing' => $missing,
|
||||
'found' => $found,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,9 +45,10 @@ class ValidateServer
|
||||
throw new \Exception($this->error);
|
||||
}
|
||||
|
||||
$prerequisitesInstalled = $server->validatePrerequisites();
|
||||
if (! $prerequisitesInstalled) {
|
||||
$this->error = 'Prerequisites (git, curl, jq) are not installed. Please install them before continuing or use the validation with installation endpoint.';
|
||||
$validationResult = $server->validatePrerequisites();
|
||||
if (! $validationResult['success']) {
|
||||
$missingCommands = implode(', ', $validationResult['missing']);
|
||||
$this->error = "Prerequisites ({$missingCommands}) are not installed. Please install them before continuing or use the validation with installation endpoint.";
|
||||
$server->update([
|
||||
'validation_logs' => $this->error,
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user