IcingaCommandArgument: render set_if without format
Icinga DSL support was introduced in 348cb1aa6
and works fine, but breaks
rendering of legacy arguments with set_if_format = NULL. This should default
to 'string', as we should IMO not force NOT NULL in the DB in this case.
refs #12153
fixes #12886
This commit is contained in:
parent
380fb0afe9
commit
c4da25ef25
|
@ -163,12 +163,13 @@ class IcingaCommandArgument extends IcingaObject
|
|||
|
||||
if ($this->set_if) {
|
||||
switch ($this->set_if_format) {
|
||||
case 'string':
|
||||
$data['set_if'] = c::renderString($this->set_if);
|
||||
break;
|
||||
case 'expression':
|
||||
$data['set_if'] = c::renderExpression($this->set_if);
|
||||
break;
|
||||
case 'string':
|
||||
default:
|
||||
$data['set_if'] = c::renderString($this->set_if);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -174,6 +174,22 @@ class IcingaCommandTest extends BaseTestCase
|
|||
);
|
||||
}
|
||||
|
||||
public function testSimpleSetIfIsRendered()
|
||||
{
|
||||
$command = $this->command();
|
||||
$command->command = 'bla';
|
||||
$command->arguments = array(
|
||||
'-a' => (object) array(
|
||||
'set_if' => '$a$',
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
$this->loadRendered('command7'),
|
||||
(string) $command
|
||||
);
|
||||
}
|
||||
|
||||
protected function command()
|
||||
{
|
||||
return IcingaCommand::create(
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
object CheckCommand "___TEST___command" {
|
||||
command = [ PluginDir + "/bla" ]
|
||||
arguments = {
|
||||
"-a" = {
|
||||
set_if = "$a$"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue