Skip to content

Commit

Permalink
cleanup custom checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy132 committed Dec 13, 2024
1 parent 6e15de3 commit aebfc48
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
9 changes: 5 additions & 4 deletions app/Checks/NodeVersionsCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

class NodeVersionsCheck extends Check
{
public function __construct(private SoftwareVersionService $versionService) {}

public function run(): Result
{
$all = Node::query()->count();
Expand All @@ -21,8 +23,7 @@ public function run(): Result
return $result;
}

// @phpstan-ignore-next-line
$latestVersion = app(SoftwareVersionService::class)->latestWingsVersion();
$latestVersion = $this->versionService->latestWingsVersion();

$outdated = Node::query()->get()
->filter(fn (Node $node) => !isset($node->systemInformation()['exception']) && $node->systemInformation()['version'] !== $latestVersion)
Expand All @@ -36,7 +37,7 @@ public function run(): Result
->shortSummary($outdated === 0 ? 'All up-to-date' : "{$outdated}/{$all} outdated");

return $outdated === 0
? $result->ok('All Nodes are up-to-date')
: $result->failed("`{$outdated}`/`{$all}` Nodes are outdated");
? $result->ok('All Nodes are up-to-date.')
: $result->failed(':outdated/:all Nodes are outdated.');
}
}
15 changes: 7 additions & 8 deletions app/Checks/PanelVersionCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@

class PanelVersionCheck extends Check
{
public function __construct(private SoftwareVersionService $versionService) {}

public function run(): Result
{
/** @var SoftwareVersionService $versionService */
$versionService = app(SoftwareVersionService::class); // @phpstan-ignore-line

$isLatest = $versionService->isLatestPanel();
$currentVersion = $versionService->currentPanelVersion();
$latestVersion = $versionService->latestPanelVersion();
$isLatest = $this->versionService->isLatestPanel();
$currentVersion = $this->versionService->currentPanelVersion();
$latestVersion = $this->versionService->latestPanelVersion();

$result = Result::make()
->meta([
Expand All @@ -26,7 +25,7 @@ public function run(): Result
->shortSummary($isLatest ? 'up-to-date' : 'outdated');

return $isLatest
? $result->ok('Panel is up-to-date')
: $result->failed("Installed version is `{$currentVersion}` but latest is `{$latestVersion}`");
? $result->ok('Panel is up-to-date.')
: $result->failed('Installed version is `:currentVersion` but latest is `:latestVersion`.');
}
}

0 comments on commit aebfc48

Please sign in to comment.