Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

andrewvc
Copy link
Contributor

@andrewvc andrewvc commented Nov 1, 2018

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.

@andrewvc andrewvc added enhancement in progress Pull request is currently in progress. libbeat labels Nov 1, 2018
@andrewvc andrewvc added review and removed in progress Pull request is currently in progress. labels Nov 1, 2018
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 {
Copy link
Contributor

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)) {
, then you don't need the overhead of adding a new bool condition to the conditions package

@jsoriano
Copy link
Member

jsoriano commented Nov 8, 2018

This would fix #7310

@andrewvc
Copy link
Contributor Author

andrewvc commented Nov 8, 2018

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'.

@andrewvc
Copy link
Contributor Author

Closing in favor of #9029 which just makes conditions in autodiscover nullable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants