-
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
No condition required for autodiscover. Bool condition added #8897
Conversation
This patch allows you to use the autodiscover without any filtering via conditions. I initially considered doing this by making the condition nullable via a pointer, but then decided that boolean conditions can be convenient (and are as fast for this purpose) and might be generally nice for the conditions language. So, instead, this accomplishes the same by inserting an always true condition if the conditions config option is omitted.
return nil, err | ||
condMap := &ConditionMap{Configs: c.Configs} | ||
|
||
if c.ConditionConfig == nil { |
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.
You could be doing this nil
check here:
if mapping.Configs != nil && !mapping.Condition.Check(Event(event)) { |
conditions
package
This would fix #7310 |
Thinking about this further, I think @exekias is right that we should just have an empty condition. In most expression languages you do have a boolean literal, but this isn't a normal language. The number of use cases for that are small. Given that, I'll open a new PR soon that checks for a nullable pointer and assumes that is always 'true'. |
Closing in favor of #9029 which just makes conditions in autodiscover nullable. |
This patch allows you to use the autodiscover without any filtering via conditions. Today, if you want to disable the conditions syntax on autodiscover you have to makeup a weird condition that does nothing (like checking for the hostname, if it's always there).
I initially considered doing this by making the condition nullable via a pointer, but
then decided that boolean conditions can be convenient (and are as fast for this purpose)
and might be generally nice for the conditions language.
So, instead, this accomplishes the same by inserting an always true condition if the
conditions config option is omitted.