Add managed registry provisioning, pruning, and readiness tracking
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Registries;
|
||||
|
||||
use App\Enums\OperationKind;
|
||||
use App\Enums\OperationStatus;
|
||||
use App\Models\Operation;
|
||||
use App\Models\Registry;
|
||||
use App\Models\Server;
|
||||
use App\Services\Registries\ManagedRegistryOperationScripts;
|
||||
use RuntimeException;
|
||||
|
||||
class CreateManagedRegistryProvisionOperation
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ManagedRegistryOperationScripts $scripts,
|
||||
) {}
|
||||
|
||||
public function execute(Registry $registry): Operation
|
||||
{
|
||||
$server = $registry->controlServer;
|
||||
|
||||
if (! $server instanceof Server) {
|
||||
throw new RuntimeException('A control/build server is required to provision the managed registry.');
|
||||
}
|
||||
|
||||
$provision = $this->scripts->provision($registry);
|
||||
|
||||
$operation = $server->operations()->create([
|
||||
'kind' => OperationKind::REGISTRY_PROVISION,
|
||||
'status' => OperationStatus::PENDING,
|
||||
]);
|
||||
|
||||
$operation->steps()->create([
|
||||
'name' => 'Install managed Docker registry',
|
||||
'order' => 1,
|
||||
'status' => OperationStatus::PENDING,
|
||||
'script' => $provision['script'],
|
||||
'secrets' => $provision['secrets'],
|
||||
]);
|
||||
|
||||
return $operation->refresh();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user