From 05d7e137c24dda520f2101eb8dd47aae93a88416 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Mon, 18 Jul 2022 10:08:51 +0200 Subject: [PATCH] IcingaArguments: clarify reason for missing DSL... ...in External Commands imported via Icinga 2 API fixes #2557 --- library/Director/Objects/IcingaArguments.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/library/Director/Objects/IcingaArguments.php b/library/Director/Objects/IcingaArguments.php index d00fe684..e788da8c 100644 --- a/library/Director/Objects/IcingaArguments.php +++ b/library/Director/Objects/IcingaArguments.php @@ -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'])) {