UpdateImageCommand::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace Joli\JoliCi\Command;
4
5
use Joli\JoliCi\Container;
6
use Symfony\Component\Console\Command\Command;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\OutputInterface;
9
use Symfony\Component\Console\Input\InputArgument;
10
use Symfony\Component\Console\Input\InputOption;
11
12
class UpdateImageCommand extends Command
13
{
14
    /**
15
     * {@inheritdoc}
16
     */
17
    protected function configure()
18
    {
19
        $this->setName('images-update');
20
        $this->setDescription('Update docker images used to build test environnement');
21
    }
22
23
    /**
24
     * {@inheritdoc}
25
     */
26
    protected function execute(InputInterface $input, OutputInterface $output)
27
    {
28
        $container = new Container();
29
        $docker = $container->getDocker();
30
        $logger = $container->getLoggerCallback((OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()));
31
32
        foreach ($docker->getImageManager()->findAll() as $image) {
33
            if (preg_match('#^jolicode/(.+?)$#', $image->getRepository())) {
34
                $output->writeln(sprintf("Update %s image", $image->getRepository()));
35
                $docker->getImageManager()->pull($image->getRepository(), 'latest', $logger->getBuildCallback());
36
            }
37
        }
38
    }
39
}
40