Skip to content

Commit

Permalink
include mongoclient for filter plugin (#669)
Browse files Browse the repository at this point in the history
  • Loading branch information
pvkas authored and rwynn committed Apr 8, 2023
1 parent 170ebed commit aaa54fb
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions monstache.go
Original file line number Diff line number Diff line change
Expand Up @@ -1423,7 +1423,7 @@ func filterDropWithRegex(regex string) gtm.OpFilter {
}
}

func filterWithPlugin() gtm.OpFilter {
func filterWithPlugin(mc *mongo.Client) gtm.OpFilter {
return func(op *gtm.Op) bool {
var keep = true
if (op.IsInsert() || op.IsUpdate()) && op.Data != nil {
Expand All @@ -1435,6 +1435,7 @@ func filterWithPlugin() gtm.OpFilter {
Collection: op.GetCollection(),
Operation: op.Operation,
UpdateDescription: op.UpdateDescription,
MongoClient: mc,
}
if ok, err := filterPlugin(input); err == nil {
keep = ok
Expand Down Expand Up @@ -4690,7 +4691,7 @@ func (ic *indexClient) buildFilterArray() []gtm.OpFilter {
errorLog.Fatalln("Workers configured but this worker is undefined. worker must be set to one of the workers.")
}
if filterPlugin != nil {
pluginFilter = filterWithPlugin()
pluginFilter = filterWithPlugin(ic.mongo)
filterArray = append(filterArray, pluginFilter)
} else if len(filterEnvs) > 0 {
pluginFilter = filterWithScript()
Expand Down

0 comments on commit aaa54fb

Please sign in to comment.