8 padWidth = width - stringLength str;
9 padding = concatStrings (genList (const " ") padWidth);
10 in str + optionalString (padWidth > 0) padding;
12 if k == "check_command" && builtins.isList v
13 then builtins.concatStringsSep "!" v
16 toService = service: ''
18 ${builtins.concatStringsSep "\n" (mapAttrsToList (k: v:
19 " ${pad 30 k} ${toStr k v}"
20 ) (filterAttrs (k: v: ! builtins.elem k ["passiveInfo" "filter"]) service))}
23 toServices = services: builtins.concatStringsSep "\n" (map toService services);
27 ${pad 30 "command_name"} ${k}
28 ${pad 30 "command_line"} ${v}
31 toCommands = a: builtins.concatStringsSep "\n" (mapAttrsToList toCommand a);
33 toOther = keyname: k: v: ''
35 ${pad 30 "${keyname}_name"} ${k}
36 ${builtins.concatStringsSep "\n" (mapAttrsToList (kk: vv:
41 toOthers = keyname: a: builtins.concatStringsSep "\n" (mapAttrsToList (toOther keyname) a);
43 toTemplate = keyname: k: v: ''
46 ${pad 30 "register"} 0
47 ${builtins.concatStringsSep "\n" (mapAttrsToList (kk: vv:
52 toTemplates' = keyname: a: builtins.concatStringsSep "\n" (mapAttrsToList (toTemplate keyname) a);
53 toTemplates = v: builtins.concatStringsSep "\n" (mapAttrsToList toTemplates' v);
55 toObjects' = keyname: v:
56 if keyname == "service"
58 else if keyname == "command"
60 else if keyname == "templates"
62 else if builtins.elem keyname ["hostgroup" "host" "contactgroup" "contact" "timeperiod" "servicegroup"]
63 then toOthers keyname v
65 toObjects = v: builtins.concatStringsSep "\n" (mapAttrsToList toObjects' v);