diff options
author | Valentin Rothberg <rothberg@redhat.com> | 2021-06-01 09:33:02 +0200 |
---|---|---|
committer | Valentin Rothberg <rothberg@redhat.com> | 2021-06-02 13:37:56 +0200 |
commit | 37f39eefee72ec4fb6c6bd71642e9d384c448387 (patch) | |
tree | b92e5c34040d2843af14f0892e4165d0d1c17380 /libpod/events/logfile.go | |
parent | 8f5f0cf44898a5785a0fb2cf814969e13ab17a3c (diff) | |
download | podman-37f39eefee72ec4fb6c6bd71642e9d384c448387.tar.gz podman-37f39eefee72ec4fb6c6bd71642e9d384c448387.tar.bz2 podman-37f39eefee72ec4fb6c6bd71642e9d384c448387.zip |
events: support disjunctive filters
While different filters are applied in conjunction, the same filter (but
with different values) should be applied in disjunction. This allows,
for instance, to query the events of two containers.
Fixes: #10507
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'libpod/events/logfile.go')
-rw-r--r-- | libpod/events/logfile.go | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/libpod/events/logfile.go b/libpod/events/logfile.go index 0f00525e8..952444f2b 100644 --- a/libpod/events/logfile.go +++ b/libpod/events/logfile.go @@ -44,9 +44,9 @@ func (e EventLogFile) Write(ee Event) error { // Reads from the log file func (e EventLogFile) Read(ctx context.Context, options ReadOptions) error { defer close(options.EventChannel) - eventOptions, err := generateEventOptions(options.Filters, options.Since, options.Until) + filterMap, err := generateEventFilters(options.Filters, options.Since, options.Until) if err != nil { - return errors.Wrapf(err, "unable to generate event options") + return errors.Wrapf(err, "failed to parse event filters") } t, err := e.getTail(options) if err != nil { @@ -92,11 +92,7 @@ func (e EventLogFile) Read(ctx context.Context, options ReadOptions) error { default: return errors.Errorf("event type %s is not valid in %s", event.Type.String(), e.options.LogFilePath) } - include := true - for _, filter := range eventOptions { - include = include && filter(event) - } - if include && copy { + if copy && applyFilters(event, filterMap) { options.EventChannel <- event } } |