Add managed registry provisioning, pruning, and readiness tracking
This commit is contained in:
49
app/Console/Commands/CheckManagedRegistry.php
Normal file
49
app/Console/Commands/CheckManagedRegistry.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Actions\Registries\CreateManagedRegistrySmokeCheckOperation;
|
||||
use App\Enums\RegistryType;
|
||||
use App\Models\Registry;
|
||||
use App\Models\Server;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class CheckManagedRegistry extends Command
|
||||
{
|
||||
protected $signature = 'keystone:managed-registry:check
|
||||
{registry : Managed registry id}
|
||||
{--build-server= : Build server id, defaults to the registry control server}
|
||||
{--runtime-server=* : Runtime server id to pull the smoke image}
|
||||
{--dispatch : Dispatch the first operation step immediately}';
|
||||
|
||||
protected $description = 'Create managed registry HTTPS/auth/push/pull smoke-check operations.';
|
||||
|
||||
public function handle(CreateManagedRegistrySmokeCheckOperation $operations): int
|
||||
{
|
||||
$registry = Registry::query()
|
||||
->where('type', RegistryType::MANAGED->value)
|
||||
->findOrFail((int) $this->argument('registry'));
|
||||
|
||||
$buildServer = $this->option('build-server')
|
||||
? Server::query()
|
||||
->where('organisation_id', $registry->organisation_id)
|
||||
->findOrFail((int) $this->option('build-server'))
|
||||
: null;
|
||||
|
||||
$runtimeServers = collect($this->option('runtime-server'))
|
||||
->map(fn (string $serverId): Server => Server::query()
|
||||
->where('organisation_id', $registry->organisation_id)
|
||||
->findOrFail((int) $serverId));
|
||||
|
||||
$operation = $operations->execute($registry, $buildServer, $runtimeServers);
|
||||
|
||||
$this->info("Created registry smoke-check operation {$operation->id}.");
|
||||
|
||||
if ($this->option('dispatch')) {
|
||||
$operation->steps()->orderBy('order')->first()?->dispatchJob();
|
||||
$this->info('Dispatched registry smoke-check operation.');
|
||||
}
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user