Skip to content

Commit

Permalink
Icinga DB: serialize icinga:config:checkcommand:argument#value and #s…
Browse files Browse the repository at this point in the history
…et_if as expected

I.e. keep the serializations as simple as possible:

null     => null
true     => true
42.0     => 42
"foobar" => foobar
{{42}}   => Object of type 'Function'

(["foobar"] and {"foo"="bar"} can't occur there.)
  • Loading branch information
Al2Klimov committed Apr 30, 2021
1 parent b08b30e commit f5abec2
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions lib/icingadb/icingadb-objects.cpp
Expand Up @@ -972,12 +972,20 @@ void IcingaDB::InsertObjectDependencies(const ConfigObject::Ptr& object, const S
values = new Dictionary({{"value", kv.second}});
}

{
for (const char *attr : {"value", "set_if"}) {
Value value;

// JsonEncode() the value if it's set.
if (values->Get("value", &value)) {
values->Set("value", JsonEncode(value));
// Stringify if set.
if (values->Get(attr, &value)) {
switch (value.GetType()) {
case ValueString:
break;
case ValueObject:
values->Set(attr, value.Get<Object::Ptr>()->ToString());
break;
default:
values->Set(attr, JsonEncode(value));
}
}
}

Expand Down

0 comments on commit f5abec2

Please sign in to comment.