Add key param to deployment status cli

This commit is contained in:
Gianluca Piccolo 2020-10-07 17:10:19 +02:00 committed by Thomas Gelf
parent 0a54fda6b6
commit 533d2d7b77
2 changed files with 13 additions and 4 deletions

View File

@ -4,8 +4,10 @@ namespace Icinga\Module\Director\Clicommands;
use Icinga\Application\Benchmark;
use Icinga\Module\Director\Cli\Command;
use Icinga\Module\Director\Core\Json;
use Icinga\Module\Director\Deployment\DeploymentStatus;
use Icinga\Module\Director\IcingaConfig\IcingaConfig;
use Icinga\Module\Director\Import\SyncUtils;
/**
* Generate, show and deploy Icinga 2 configuration
@ -130,7 +132,14 @@ class ConfigCommand extends Command
$api = $this->api();
$status = new DeploymentStatus($db, $api);
$result = $status->getDeploymentStatus($this->params->get('configs'), $this->params->get('activities'));
if ($key = $this->params->get('key')) {
$result = SyncUtils::getSpecificValue($result, $key);
}
printf(json_encode($result));
if (is_string($result)) {
echo "$result\n";
} else {
echo Json::encode($result, JSON_PRETTY_PRINT) . "\n";
}
}
}

View File

@ -46,19 +46,19 @@ class DeploymentStatus
];
if ($configs) {
$result['configs'] = $this->getDeploymentStatusForConfigChecksums(
$result['configs'] = (object) $this->getDeploymentStatusForConfigChecksums(
explode(',', $configs),
$configChecksum
);
}
if ($activities) {
$result['activities'] = $this->getDeploymentStatusForActivityLogChecksums(
$result['activities'] = (object) $this->getDeploymentStatusForActivityLogChecksums(
explode(',', $activities),
$lastActivityLogChecksum
);
}
return $result;
return (object) $result;
}
public function getConfigChecksumForStageName($stageName)