Add managed registry provisioning, pruning, and readiness tracking
This commit is contained in:
47
app/Services/Registries/RegistryResolver.php
Normal file
47
app/Services/Registries/RegistryResolver.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Registries;
|
||||
|
||||
use App\Enums\RegistryType;
|
||||
use App\Models\Organisation;
|
||||
use App\Models\Registry;
|
||||
|
||||
class RegistryResolver
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ManagedRegistryHealth $managedRegistryHealth,
|
||||
) {}
|
||||
|
||||
public function buildRegistryFor(Organisation $organisation): ?Registry
|
||||
{
|
||||
$externalRegistry = $organisation->registries()
|
||||
->where('type', '!=', RegistryType::MANAGED->value)
|
||||
->first();
|
||||
|
||||
if ($externalRegistry instanceof Registry) {
|
||||
return $externalRegistry;
|
||||
}
|
||||
|
||||
$managedRegistry = $organisation->registries()
|
||||
->where('type', RegistryType::MANAGED->value)
|
||||
->first();
|
||||
|
||||
if ($managedRegistry instanceof Registry) {
|
||||
return $this->managedRegistryHealth->readinessBlocker($managedRegistry) === null ? $managedRegistry : null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function managedRegistryBlockerFor(Organisation $organisation): ?string
|
||||
{
|
||||
$managedRegistry = $organisation->registries()
|
||||
->where('type', RegistryType::MANAGED->value)
|
||||
->with('controlServer')
|
||||
->first();
|
||||
|
||||
return $managedRegistry instanceof Registry
|
||||
? $this->managedRegistryHealth->readinessBlocker($managedRegistry)
|
||||
: null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user