| Total Complexity | 4 |
| Total Lines | 29 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | class ContainerIsRunningCheck implements Check |
||
| 10 | { |
||
| 11 | const IDENTIFIER = 'base:docker:container:running'; |
||
| 12 | |||
| 13 | private $containerName; |
||
| 14 | |||
| 15 | public function init($containerName) |
||
| 18 | } |
||
| 19 | |||
| 20 | public function run() |
||
| 21 | { |
||
| 22 | $command = "docker inspect -f '{{.State.Running}}' " . $this->containerName . " 2>/dev/null "; |
||
| 23 | |||
| 24 | exec($command, $output, $returnValue); |
||
| 25 | |||
| 26 | $isRunning = ((bool)$output[0]); |
||
| 27 | |||
| 28 | if ($isRunning) { |
||
| 29 | return new Result(Result::STATUS_PASS, 'The container ' . $this->containerName . ' is running.'); |
||
| 30 | } else { |
||
| 31 | return new Result(Result::STATUS_FAIL, 'The container ' . $this->containerName . ' is not running.'); |
||
| 32 | } |
||
| 33 | } |
||
| 34 | |||
| 35 | public function getIdentifier() |
||
| 38 | } |
||
| 39 | } |
||
| 40 |