Skip to content

Commit

Permalink
IcingaArguments: clarify reason for missing DSL...
Browse files Browse the repository at this point in the history
...in External Commands imported via Icinga 2 API

fixes #2557
  • Loading branch information
Thomas-Gelf committed Jul 18, 2022
1 parent fe3d5c7 commit 05d7e13
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions library/Director/Objects/IcingaArguments.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

class IcingaArguments implements Iterator, Countable, IcingaConfigRenderer
{
const COMMENT_DSL_UNSUPPORTED = '/* Icinga 2 does not export DSL function bodies via API */';

/** @var IcingaCommandArgument[] */
protected $storedArguments = [];

Expand Down Expand Up @@ -153,7 +155,7 @@ protected function mungeCommandArgument($key, $value)
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')) {
Expand All @@ -164,7 +166,7 @@ protected function mungeCommandArgument($key, $value)
$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');
Expand Down Expand Up @@ -192,7 +194,7 @@ protected function mungeCommandArgument($key, $value)

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'])) {
Expand Down

0 comments on commit 05d7e13

Please sign in to comment.