Command: remove custom JSON logic
This commit is contained in:
parent
535bdfd23d
commit
6d5c48125e
|
@ -2,12 +2,12 @@
|
||||||
|
|
||||||
namespace Icinga\Module\Director\Cli;
|
namespace Icinga\Module\Director\Cli;
|
||||||
|
|
||||||
|
use gipfl\Json\JsonDecodeException;
|
||||||
use gipfl\Json\JsonString;
|
use gipfl\Json\JsonString;
|
||||||
use Icinga\Cli\Command as CliCommand;
|
use Icinga\Cli\Command as CliCommand;
|
||||||
use Icinga\Module\Director\Application\MemoryLimit;
|
use Icinga\Module\Director\Application\MemoryLimit;
|
||||||
use Icinga\Module\Director\Core\CoreApi;
|
use Icinga\Module\Director\Core\CoreApi;
|
||||||
use Icinga\Module\Director\Db;
|
use Icinga\Module\Director\Db;
|
||||||
use Icinga\Module\Director\Exception\JsonException;
|
|
||||||
use Icinga\Module\Director\Objects\IcingaEndpoint;
|
use Icinga\Module\Director\Objects\IcingaEndpoint;
|
||||||
use Icinga\Application\Config;
|
use Icinga\Application\Config;
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
|
@ -31,13 +31,11 @@ class Command extends CliCommand
|
||||||
*/
|
*/
|
||||||
protected function parseJson($json)
|
protected function parseJson($json)
|
||||||
{
|
{
|
||||||
$res = json_decode($json);
|
try {
|
||||||
|
return JsonString::decode($json);
|
||||||
if ($res === null) {
|
} catch (JsonDecodeException $e) {
|
||||||
$this->fail('Invalid JSON: %s', $this->getLastJsonError());
|
$this->fail('Invalid JSON: %s', $e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return $res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function fail($msg)
|
public function fail($msg)
|
||||||
|
@ -51,14 +49,6 @@ class Command extends CliCommand
|
||||||
throw new RuntimeException($msg);
|
throw new RuntimeException($msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
protected function getLastJsonError()
|
|
||||||
{
|
|
||||||
return JsonException::getJsonErrorMessage(json_last_error());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param null $endpointName
|
* @param null $endpointName
|
||||||
* @return CoreApi|\Icinga\Module\Director\Core\LegacyDeploymentApi
|
* @return CoreApi|\Icinga\Module\Director\Core\LegacyDeploymentApi
|
||||||
|
|
Loading…
Reference in New Issue