2022-03-07 21:45:54 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace NoccyLabs\FreshDocker\Configuration;
|
|
|
|
|
|
|
|
use Symfony\Component\Yaml\Yaml;
|
|
|
|
|
2022-03-08 23:38:57 +00:00
|
|
|
class ComposeConfiguration
|
2022-03-07 21:45:54 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
private array $checks = [];
|
|
|
|
|
|
|
|
public function __construct(string $configfile)
|
|
|
|
{
|
|
|
|
$this->loadComposeFile($configfile);
|
|
|
|
}
|
|
|
|
|
|
|
|
private function loadComposeFile($configfile)
|
|
|
|
{
|
|
|
|
$config = Yaml::parseFile($configfile);
|
|
|
|
$services = $config['services']??[];
|
|
|
|
foreach ($services as $name=>$service) {
|
|
|
|
$image = $service['image']??null;
|
|
|
|
if ($image && !in_array($image,$this->checks)) {
|
|
|
|
$this->checks[] = $image;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getChecks(): array
|
|
|
|
{
|
|
|
|
return $this->checks;
|
|
|
|
}
|
|
|
|
}
|