You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
931 B
PHP
32 lines
931 B
PHP
<?php
|
|
|
|
namespace App\Command;
|
|
|
|
use App\Services\Cloud\CloudInstanceMetadataRepairService;
|
|
|
|
final class CloudRepairInstanceMetadata
|
|
{
|
|
public static function run(array $argv): int
|
|
{
|
|
$apply = in_array('--apply', $argv, true);
|
|
$limit = 10000;
|
|
$afterId = 0;
|
|
foreach ($argv as $argument) {
|
|
if (preg_match('/^--limit=([0-9]{1,5})$/D',
|
|
(string) $argument, $match) === 1) {
|
|
$limit = (int) $match[1];
|
|
}
|
|
if (preg_match('/^--after-id=([0-9]{1,18})$/D',
|
|
(string) $argument, $match) === 1) {
|
|
$afterId = (int) $match[1];
|
|
}
|
|
}
|
|
$result = CloudInstanceMetadataRepairService::run(
|
|
$apply, $limit, $afterId
|
|
);
|
|
echo json_encode($result, JSON_THROW_ON_ERROR
|
|
| JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . PHP_EOL;
|
|
return 0;
|
|
}
|
|
}
|