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

Support for standalone booleans in conditions #297

Closed
wants to merge 1 commit into from

Conversation

mkanoor
Copy link
Contributor

@mkanoor mkanoor commented Jan 18, 2023

This helps when we want to print events without knowing the contents of the event.
The literal boolean true allows the condition to pass and the action print_event can be used to print the event

This would usually be used for bulding the rulebook, you would not use it in production.

    - name: print event always
      condition: true
      action:
        print_event:
          pretty: true

Once you have satisfied with getting the event data you can disable this rule by using

    - name: never run
      condition: false
      action:
        print_event:
          pretty: true

In programming parlance this is equivalent to doing

   if true:
     .....

or

   if false:
     .....

An easier way to comment out a condition

This helps when we want to print events without knowing
the contents of the event.
The literal boolean true allows the condition to pass
and the action print_event can be used to print the event

This would usually be used for bulding the rulebook, you would
not use it in production.

```
    - name: print event always
      condition: true
      action:
        print_event:
          pretty: true
```
@Alex-Izquierdo
Copy link
Contributor

I think this could be a good replacement for the --print-all-events flag, isn't? @benthomasson
https://issues.redhat.com/browse/AAP-8089

I personally prefer a statement in the rulebook instead of a flag.

Copy link
Contributor

@benthomasson benthomasson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure this is the right way to print events.

@mkanoor mkanoor closed this Jan 19, 2023
@AssafKatz3
Copy link

Hi @Alex-Izquierdo and @benthomasson,
I have another use case for it - we want to process all Kafka events on a topic. And I believe that we will have more use cases for this option.
Thanks

@Alex-Izquierdo
Copy link
Contributor

Hi @AssafKatz3 I suggest to open a new feature request for it. Anyway, this is currently possible.
You can write a condition that will always match. So, if you events will contain a name field, you can use event.name is defined

Even if the schema of your events is dynamic and you can not ensure the existence of a certain field, you can write your own filter to add it.

@AssafKatz3
Copy link

AssafKatz3 commented Mar 15, 2023

@Alex-Izquierdo I opened feature request. I cannot see how a custom filter will help me, I will still need the condition.

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

Successfully merging this pull request may close these issues.

4 participants