fresh/src/Configuration/ComposeConfiguration.php
Christopher Vagnetoft ec1659e96d Refactoring and cleanup
* Moved logic from entrypoint to a dedicated class.
* Disabled automatic flush of state.
* Added locking support to prevent multiple instances.
* Added logging
* Added base interface for CredentialsLoader
2022-03-09 01:09:28 +01:00

33 lines
722 B
PHP

<?php
namespace NoccyLabs\FreshDocker\Configuration;
use Symfony\Component\Yaml\Yaml;
class ComposeConfiguration
{
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;
}
}