56 lines
1.4 KiB
PHP
56 lines
1.4 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
namespace App\Command;
|
||
|
|
|
||
|
|
use App\Service\ArmImageDownloader;
|
||
|
|
use Doctrine\Common\Collections\Collection;
|
||
|
|
use Exception;
|
||
|
|
use Symfony\Component\Console\Command\Command;
|
||
|
|
use Symfony\Component\Console\Input\InputInterface;
|
||
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
||
|
|
|
||
|
|
class EnsureImagePresent extends Command
|
||
|
|
{
|
||
|
|
use SharedStorage,
|
||
|
|
AutoOptions;
|
||
|
|
|
||
|
|
const NAME = "standalone:image:ensure-present";
|
||
|
|
const OPTIONS = [
|
||
|
|
"remote-host",
|
||
|
|
"image-store",
|
||
|
|
"r-state",
|
||
|
|
];
|
||
|
|
|
||
|
|
/** @var ArmImageDownloader */
|
||
|
|
private $downloader;
|
||
|
|
|
||
|
|
public function __construct(ArmImageDownloader $downloader, Collection $storage)
|
||
|
|
{
|
||
|
|
$this->downloader = $downloader;
|
||
|
|
$this->sharedStorage = $storage;
|
||
|
|
parent::__construct();
|
||
|
|
}
|
||
|
|
|
||
|
|
protected function configure()
|
||
|
|
{
|
||
|
|
$this->setName(self::NAME)->setDescription('Generate onboard package');
|
||
|
|
$this->configureOptions();;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @param InputInterface $input
|
||
|
|
* @param OutputInterface $output
|
||
|
|
* @throws Exception
|
||
|
|
*/
|
||
|
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||
|
|
{
|
||
|
|
$functionArgs = $this->getFunctionArgs($input);
|
||
|
|
if ($this->downloader->isRemoteImageMissing(...$functionArgs)) {
|
||
|
|
$this->downloader->downloadImageToRemote(...$functionArgs);
|
||
|
|
}
|
||
|
|
$this->downloader->uncompressImage(...$functionArgs);
|
||
|
|
}
|
||
|
|
}
|