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 toOtherNoName = keyname: v: ''
43 ${builtins.concatStringsSep "\n" (mapAttrsToList (kk: vv:
48 toOthers = keyname: a: builtins.concatStringsSep "\n" (mapAttrsToList (toOther keyname) a);
49 toOthersArray = keyname: a: builtins.concatStringsSep "\n" (map (toOtherNoName keyname) a);
51 toTemplate = keyname: k: v: ''
54 ${pad 30 "register"} 0
55 ${builtins.concatStringsSep "\n" (mapAttrsToList (kk: vv:
60 toTemplates' = keyname: a: builtins.concatStringsSep "\n" (mapAttrsToList (toTemplate keyname) a);
61 toTemplates = v: builtins.concatStringsSep "\n" (mapAttrsToList toTemplates' v);
63 toObjects' = keyname: v:
64 if keyname == "service"
66 else if keyname == "command"
68 else if keyname == "templates"
70 else if builtins.elem keyname ["hostgroup" "host" "contactgroup" "contact" "timeperiod" "servicegroup"]
71 then toOthers keyname v
72 else if builtins.elem keyname ["servicedependency"]
73 then toOthersArray keyname v
75 toObjects = v: builtins.concatStringsSep "\n" (mapAttrsToList toObjects' v);