IcingaArguments: clarify reason for missing DSL...

...in External Commands imported via Icinga 2 API

fixes #2557
This commit is contained in:
Thomas Gelf 2022-07-18 10:08:51 +02:00
parent fe3d5c7076
commit 05d7e137c2

View File

@ -11,6 +11,8 @@ use Iterator;
class IcingaArguments implements Iterator, Countable, IcingaConfigRenderer
{
const COMMENT_DSL_UNSUPPORTED = '/* Icinga 2 does not export DSL function bodies via API */';
/** @var IcingaCommandArgument[] */
protected $storedArguments = [];
@ -153,7 +155,7 @@ class IcingaArguments implements Iterator, Countable, IcingaConfigRenderer
if (property_exists($value, 'type')) {
// argument is directly set as function, no further properties
if ($value->type === 'Function') {
$attrs['argument_value'] = '/* Unable to fetch function body through API */';
$attrs['argument_value'] = self::COMMENT_DSL_UNSUPPORTED;
$attrs['argument_format'] = 'expression';
}
} elseif (property_exists($value, 'value')) {
@ -164,7 +166,7 @@ class IcingaArguments implements Iterator, Countable, IcingaConfigRenderer
$attrs['argument_value'] = $value->value->body;
$attrs['argument_format'] = 'expression';
} elseif ($value->value->type === 'Function') {
$attrs['argument_value'] = '/* Unable to fetch function body through API */';
$attrs['argument_value'] = self::COMMENT_DSL_UNSUPPORTED;
$attrs['argument_format'] = 'expression';
} else {
die('Unable to resolve command argument');
@ -192,7 +194,7 @@ class IcingaArguments implements Iterator, Countable, IcingaConfigRenderer
if (array_key_exists('set_if', $attrs)) {
if (is_object($attrs['set_if']) && $attrs['set_if']->type === 'Function') {
$attrs['set_if'] = '/* Unable to fetch function body through API */';
$attrs['set_if'] = self::COMMENT_DSL_UNSUPPORTED;
$attrs['set_if_format'] = 'expression';
} elseif (property_exists($value, 'set_if_format')) {
if (in_array($value->set_if_format, ['string', 'expression', 'json'])) {