Skip to content

Commit

Permalink
Merge pull request #190 from nokia/fix188
Browse files Browse the repository at this point in the history
do not resolve env vars for jq processor fields
  • Loading branch information
karimra authored Jul 31, 2023
2 parents 8fa91ac + 484e233 commit dce3d0f
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
2 changes: 1 addition & 1 deletion config/processors.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (c *Config) GetEventProcessors() (map[string]map[string]interface{}, error)
c.Processors[n] = es
}
for n := range c.Processors {
expandMapEnv(c.Processors[n])
expandMapEnv(c.Processors[n], "expression", "condition")
}
if c.Debug {
c.logger.Printf("processors: %+v", c.Processors)
Expand Down
41 changes: 41 additions & 0 deletions formatters/event_jq/event_jq_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,47 @@ var testset = map[string]struct {
},
},
},
"expression_with_$var": {
processorType: processorType,
processor: map[string]interface{}{
"condition": `.values | has("a")`,
"expression": `.[] | .values.a as $x | .values.b=$x+1`,
"debug": true,
},
tests: []item{
{
input: nil,
output: nil,
},
{
input: make([]*formatters.EventMsg, 0),
output: make([]*formatters.EventMsg, 0),
},
{
input: []*formatters.EventMsg{
{
Name: "sub1",
Values: map[string]interface{}{
"a": 42,
},
Tags: map[string]string{"tag1": "1"},
},
},
output: []*formatters.EventMsg{
{
Name: "sub1",
Values: map[string]interface{}{
"a": 42,
"b": 43,
},
Tags: map[string]string{
"tag1": "1",
},
},
},
},
},
},
}

func TestEventJQ(t *testing.T) {
Expand Down

0 comments on commit dce3d0f

Please sign in to comment.