|
@@ -18,30 +18,33 @@ func Process(
|
18
|
18
|
) error {
|
19
|
19
|
var scriptData script_data.Data
|
20
|
20
|
// TODO: Process more than one dataset
|
21
|
|
- for key, data := range script.ScriptData {
|
22
|
|
- scriptData.Key = key
|
23
|
|
- r, err := regexp.Compile("`" + key + "`")
|
24
|
|
- if err != nil {
|
25
|
|
- return err
|
26
|
|
- }
|
27
|
|
- match := r.Find([]byte(script.Script))
|
28
|
|
- if len(match) == 0 {
|
29
|
|
- return fmt.Errorf("no variable named %s in script %s", key, script.Key)
|
30
|
|
- }
|
|
21
|
+ if len(script.ScriptData) > 0 {
|
|
22
|
+ for key, data := range script.ScriptData {
|
|
23
|
+ scriptData.Key = key
|
|
24
|
+ r, err := regexp.Compile("`" + key + "`")
|
|
25
|
+ if err != nil {
|
|
26
|
+ return err
|
|
27
|
+ }
|
|
28
|
+ match := r.Find([]byte(script.Script))
|
|
29
|
+ if len(match) == 0 {
|
|
30
|
+ return fmt.Errorf("no variable named %s in script %s", key, script.Key)
|
|
31
|
+ }
|
31
|
32
|
|
32
|
|
- origScript := script.Script
|
|
33
|
+ origScript := script.Script
|
33
|
34
|
|
34
|
|
- for _, el := range data {
|
35
|
|
- scriptData.Value = el
|
36
|
|
- filledScript := r.ReplaceAll([]byte(origScript), []byte(el))
|
37
|
|
- script.Script = string(filledScript)
|
38
|
|
- if err = dispatchType(client, script, alerter, scriptData); err != nil {
|
39
|
|
- return err
|
|
35
|
+ for _, el := range data {
|
|
36
|
+ scriptData.Value = el
|
|
37
|
+ filledScript := r.ReplaceAll([]byte(origScript), []byte(el))
|
|
38
|
+ script.Script = string(filledScript)
|
|
39
|
+ if err = dispatchType(client, script, alerter, scriptData); err != nil {
|
|
40
|
+ return err
|
|
41
|
+ }
|
40
|
42
|
}
|
41
|
43
|
}
|
|
44
|
+ return nil
|
|
45
|
+ } else {
|
|
46
|
+ return dispatchType(client, script, alerter, nil)
|
42
|
47
|
}
|
43
|
|
-
|
44
|
|
- return nil
|
45
|
48
|
}
|
46
|
49
|
|
47
|
50
|
func dispatchType(
|