original & compiled context
This commit is contained in:
parent
eb1bea26cd
commit
8bb3b8933b
|
@ -63,13 +63,21 @@ func NewAlertContext(contextToSend map[string][]string, valueLength int) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
for key, values := range contextToSend {
|
for key, values := range contextToSend {
|
||||||
|
if _, ok := alertContext.ContextToSend[key]; !ok {
|
||||||
|
alertContext.ContextToSend[key] = make([]string, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, ok := alertContext.ContextToSendCompiled[key]; !ok {
|
||||||
alertContext.ContextToSendCompiled[key] = make([]*vm.Program, 0)
|
alertContext.ContextToSendCompiled[key] = make([]*vm.Program, 0)
|
||||||
|
}
|
||||||
|
|
||||||
for _, value := range values {
|
for _, value := range values {
|
||||||
valueCompiled, err := expr.Compile(value, exprhelpers.GetExprOptions(map[string]interface{}{"evt": &types.Event{}})...)
|
valueCompiled, err := expr.Compile(value, exprhelpers.GetExprOptions(map[string]interface{}{"evt": &types.Event{}})...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("compilation of '%s' context value failed: %v", value, err)
|
return fmt.Errorf("compilation of '%s' context value failed: %v", value, err)
|
||||||
}
|
}
|
||||||
alertContext.ContextToSendCompiled[key] = append(alertContext.ContextToSendCompiled[key], valueCompiled)
|
alertContext.ContextToSendCompiled[key] = append(alertContext.ContextToSendCompiled[key], valueCompiled)
|
||||||
|
alertContext.ContextToSend[key] = append(alertContext.ContextToSend[key], value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue