IcingaArguments: Import Icinga DSL in arguments when available from baskets

Icinga 2 will still not dump this, but in Director Baskets it is included.
This commit is contained in:
Markus Frosch 2019-03-28 11:59:32 +01:00
parent 0d3649ce3f
commit 6c00d1735d
1 changed files with 7 additions and 1 deletions

View File

@ -141,13 +141,19 @@ class IcingaArguments implements Iterator, Countable, IcingaConfigRenderer
} }
} }
if (property_exists($value, 'type')) { if (property_exists($value, 'type')) {
// argument is directly set as function, no further properties
if ($value->type === 'Function') { if ($value->type === 'Function') {
$attrs['argument_value'] = '/* Unable to fetch function body through API */'; $attrs['argument_value'] = '/* Unable to fetch function body through API */';
$attrs['argument_format'] = 'expression'; $attrs['argument_format'] = 'expression';
} }
} elseif (property_exists($value, 'value')) { } elseif (property_exists($value, 'value')) {
// argument is a dictionary with further settings
if (is_object($value->value)) { if (is_object($value->value)) {
if ($value->value->type === 'Function') { if ($value->value->type === 'Function' && property_exists($value->value, 'body')) {
// likely an export from Baskets that contains the actual function body
$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'] = '/* Unable to fetch function body through API */';
$attrs['argument_format'] = 'expression'; $attrs['argument_format'] = 'expression';
} else { } else {