Skip to content

Commit

Permalink
Fix sync rule preview in case of boolean properties
Browse files Browse the repository at this point in the history
  • Loading branch information
raviks789 committed Aug 8, 2024
1 parent 428a49f commit 861fb8e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
19 changes: 19 additions & 0 deletions data2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"apply_to": "service",
"assign_filter": "host.name=%22h1%22",
"imports": [
"nt1"
],
"notification_interval": 1,
"object_name": "n2",
"object_type": "apply",
"states": [
"Warning"
],
"types": [
"Problem"
],
"users": [
"u1"
]
}
12 changes: 12 additions & 0 deletions library/Director/Db/Branch/BranchedObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
namespace Icinga\Module\Director\Db\Branch;

use Icinga\Exception\NotFoundError;
use Icinga\Module\Director\Data\Db\DbDataFormatter;
use Icinga\Module\Director\Data\Db\DbObject;
use Icinga\Module\Director\Data\Db\DbObjectTypeRegistry;
use Icinga\Module\Director\Data\Json;
use Icinga\Module\Director\Db;
use Icinga\Module\Director\Objects\IcingaObject;
use Ramsey\Uuid\UuidInterface;
use stdClass;

Expand Down Expand Up @@ -198,7 +200,17 @@ public function applyActivity(BranchActivity $activity, Db $connection)
}
}

$dummyObject = IcingaObject::createByType(
$this->objectTable,
[],
$connection
);

foreach ($activity->getModifiedProperties()->jsonSerialize() as $key => $value) {
if ($dummyObject->propertyIsBoolean($key)) {
$value = DbDataFormatter::normalizeBoolean($value);
}

$this->changes[$key] = $value;
}

Expand Down

0 comments on commit 861fb8e

Please sign in to comment.