Skip to content

Commit

Permalink
Do not env expand regex fields
Browse files Browse the repository at this point in the history
  • Loading branch information
karimra committed Nov 10, 2024
1 parent 6e01da4 commit 05406d0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
10 changes: 5 additions & 5 deletions pkg/config/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,27 +90,27 @@ func expandMapEnv(m map[string]interface{}, fn func(string, string) string) {
for i, item := range v {
switch item := item.(type) {
case string:
v[i] = os.ExpandEnv(item)
v[i] = fn(f, item)
case map[string]interface{}:
expandMapEnv(item, fn)
case []any:
expandSliceEnv(item, fn)
expandSliceEnv(f, item, fn)
}
}
m[f] = v
}
}
}

func expandSliceEnv(s []any, fn func(string, string) string) {
func expandSliceEnv(parent string, s []any, fn func(string, string) string) {
for i, item := range s {
switch item := item.(type) {
case string:
s[i] = os.ExpandEnv(item)
s[i] = fn(parent, item)
case map[string]interface{}:
expandMapEnv(item, fn)
case []any:
expandSliceEnv(item, fn)
expandSliceEnv("", item, fn)
}
}
}
Expand Down
9 changes: 8 additions & 1 deletion pkg/config/processors.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,14 @@ func (c *Config) GetEventProcessors() (map[string]map[string]interface{}, error)
c.Processors[n] = es
}
for n := range c.Processors {
expandMapEnv(c.Processors[n], expandExcept("expression", "condition"))
expandMapEnv(c.Processors[n], expandExcept(
"expression",
"condition",
"value-names", "values",
"tag-names", "tags",
"old", "new", // strings.replace
"source", // starlark
))
}
if c.Debug {
c.logger.Printf("processors: %+v", c.Processors)
Expand Down

0 comments on commit 05406d0

Please sign in to comment.