...
1local record = {
2 kubernetes = {
3 namespace = {
4 name = "your-namespace",
5 labels = {
6 label1 = "value1",
7 label2 = "value2"
8 }
9 }
10 }
11}
12
13local function parse_configmap(configmap_file)
14 local siem_configs = {}
15
16 local function file_exists(name)
17 local f = io.open(name, "r")
18 return f ~= nil and io.close(f)
19 end
20
21 if file_exists(configmap_file) then
22 local file = io.open(configmap_file, "r")
23 if file then
24 local content = file:read("*a")
25 if content ~= '' then
26 siem_configs = decode(content)
27 end
28 file:close()
29 end
30 else
31 print("File does not exist: " .. configmap_file)
32 end
33
34 return siem_configs
35end
36
37
38print(record["kubernetes"]["namespace"]["labels"]["label1"])
39
40parse_configmap("testdata/siem/siem2.json")
View as plain text