Skip to content

Commit

Permalink
fix: use the context templater to get catalog traversal funcs
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe authored and moshloop committed Nov 18, 2024
1 parent 31b2c61 commit f77d3f0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion notification/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"slices"
"strconv"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -557,10 +558,14 @@ func GetEnvForEvent(ctx context.Context, event models.Event) (*celVariables, err
func shouldSilence(ctx context.Context, celEnv map[string]any, matchingSilences []models.NotificationSilence) bool {
for _, silence := range matchingSilences {
if silence.Filter != "" {
if ok, err := gomplate.RunTemplateBool(celEnv, gomplate.Template{Expression: string(silence.Filter)}); err != nil {
res, err := ctx.RunTemplate(gomplate.Template{Expression: string(silence.Filter)}, celEnv)
if err != nil {
ctx.Errorf("failed to run silence filter expression(%s): %v", silence.Filter, err)
logs.IfError(db.UpdateNotificationSilenceError(ctx, silence.ID.String(), err.Error()), "failed to update notification silence")
continue
} else if ok, err := strconv.ParseBool(res); err != nil {
ctx.Errorf("silence filter did not return a boolean value(%s): %v", silence.Filter, err)
logs.IfError(db.UpdateNotificationSilenceError(ctx, silence.ID.String(), err.Error()), "failed to update notification silence")
} else if !ok {
continue
}
Expand Down

0 comments on commit f77d3f0

Please sign in to comment.