From 2c189d6a609e90ab9b05bca6338bc1380cb32cae Mon Sep 17 00:00:00 2001 From: Mark Stemm Date: Wed, 9 Aug 2017 16:45:47 -0700 Subject: [PATCH] Add ability to append to lists. List nodes can now have an 'append' key. If present and true, any values in this list will be appended to the end of any existing list with the same name. It is an error to have a list with 'append' true that has a name that is not an existing list. --- userspace/engine/lua/rule_loader.lua | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/userspace/engine/lua/rule_loader.lua b/userspace/engine/lua/rule_loader.lua index 0f4d828e..7a2fe997 100644 --- a/userspace/engine/lua/rule_loader.lua +++ b/userspace/engine/lua/rule_loader.lua @@ -222,7 +222,24 @@ function load_rules(rules_content, rules_mgr, verbose, all_events, extra, replac end end - state.lists_by_name[v['list']] = v + -- Possibly append to an existing list + append = false + + if v['append'] then + append = v['append'] + end + + if append then + if state.lists_by_name[v['list']] == nil then + error ("List " ..v['list'].. " has 'append' key but no list by that name already exists") + end + + for i, elem in ipairs(v['items']) do + table.insert(state.lists_by_name[v['list']]['items'], elem) + end + else + state.lists_by_name[v['list']] = v + end elseif (v['rule']) then