Skip to content

Commit

Permalink
If the docker-config is not found, try to get it from the host-config
Browse files Browse the repository at this point in the history
  • Loading branch information
stmh committed Feb 3, 2022
1 parent 0f0526d commit 7c25ac7
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/Command/OutputCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
$blueprint = $input->getOption('blueprint');
$what = strtolower($input->getOption('what'));

if (!in_array($what, ['blueprint', 'host', 'docker', 'global'])) {
throw new \InvalidArgumentException('Unknown option for `what`');
$available_options = ['blueprint', 'host', 'docker', 'global'];
if (!in_array($what, $available_options)) {
throw new \InvalidArgumentException(sprintf(
'Unknown option for `what`. Allwoed values are %s',
'`' . implode('`, `', $available_options) . '`'
));
}

$this->readConfiguration($input);
Expand Down Expand Up @@ -94,7 +98,15 @@ protected function execute(InputInterface $input, OutputInterface $output)
];
$title = 'Output of host-configuration `' . $config . '`';
} elseif ($what == 'docker') {
$data = $this->getConfiguration()->getDockerConfig($config)->raw();
try {
$data = $this->getConfiguration()
->getDockerConfig($config)
->raw();
} catch (\Exception $e) {
$host_config = $this->getConfiguration()->getHostConfig($config);
$config = $host_config['docker']['configuration'];
$data = $this->getConfiguration()->getDockerConfig($config)->raw();
}
$data = [ $config => $data];
$title = 'Output of docker-configuration `' . $config . '`';
} elseif ($what == 'global') {
Expand Down

0 comments on commit 7c25ac7

Please sign in to comment.