Add managed registry provisioning, pruning, and readiness tracking
This commit is contained in:
40
app/Console/Commands/PruneManagedRegistry.php
Normal file
40
app/Console/Commands/PruneManagedRegistry.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Actions\Registries\CreateManagedRegistryMaintenanceOperation;
|
||||
use App\Enums\RegistryType;
|
||||
use App\Models\Registry;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class PruneManagedRegistry extends Command
|
||||
{
|
||||
protected $signature = 'keystone:managed-registry:prune
|
||||
{registry? : Managed registry id}
|
||||
{--dispatch : Dispatch the first operation step immediately}';
|
||||
|
||||
protected $description = 'Create managed registry manifest deletion and garbage-collection operations.';
|
||||
|
||||
public function handle(CreateManagedRegistryMaintenanceOperation $operations): int
|
||||
{
|
||||
$registries = Registry::query()
|
||||
->where('type', RegistryType::MANAGED->value)
|
||||
->when($this->argument('registry'), fn ($query) => $query->whereKey((int) $this->argument('registry')))
|
||||
->get();
|
||||
|
||||
$count = 0;
|
||||
|
||||
foreach ($registries as $registry) {
|
||||
$operation = $operations->execute($registry);
|
||||
$count++;
|
||||
|
||||
if ($this->option('dispatch')) {
|
||||
$operation->steps()->orderBy('order')->first()?->dispatchJob();
|
||||
}
|
||||
}
|
||||
|
||||
$this->info("Created {$count} managed registry maintenance operation(s).");
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user