50 lines
1.8 KiB
PHP
50 lines
1.8 KiB
PHP
<?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;
|
|
}
|
|
}
|