From 7c25ac7a7c6efdb7564de884533faa840aad79e4 Mon Sep 17 00:00:00 2001 From: Stephan Huber Date: Tue, 28 Dec 2021 11:00:25 +0100 Subject: [PATCH] If the docker-config is not found, try to get it from the host-config --- src/Command/OutputCommand.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/Command/OutputCommand.php b/src/Command/OutputCommand.php index 2d93e065..a0575958 100644 --- a/src/Command/OutputCommand.php +++ b/src/Command/OutputCommand.php @@ -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); @@ -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') {