* working version
This commit is contained in:
55
src/App/Command/EnsureImagePresent.php
Normal file
55
src/App/Command/EnsureImagePresent.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user