workflow-test-automation/src/App/Command/EnsureImagePresent.php

56 lines
1.4 KiB
PHP
Raw Normal View History

2020-10-15 13:02:54 +02:00
<?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);
}
}