-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhance contains condition to work on fields that are arrays of string #2248
Conversation
@@ -269,26 +269,36 @@ func (c *Condition) checkEquals(event common.MapStr) bool { | |||
} | |||
|
|||
func (c *Condition) checkContains(event common.MapStr) bool { | |||
|
|||
outer: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
argh :-(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why no love for the label? Naming?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not supported in my brain :-D
LGTM |
if !strings.Contains(*value.(*string), equalValue) { | ||
return false | ||
} | ||
case []string: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@andrewkroh why not ?
found := false
for _, s := range value.([]string) {
if strings.Contains(s, equalValue) {
found = true
}
}
if !found {
return false
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are equivalent if you add the required break
statement to the snippet above. But the code in the PR is a bit more concise.
@andrewkroh does it work without updating setContains() function? |
@andrewkroh can you please add documentation for it? |
Yes, |
I have updated to docs. See #2285 |
Addresses #2237