mirror of
https://github.com/containers/podman.git
synced 2025-08-06 11:32:07 +08:00

podman --events-backend none events should return with an error since it will never be able to actually list events. Fixes part three of #15688 Signed-off-by: Paul Holzinger <pholzing@redhat.com>
32 lines
747 B
Go
32 lines
747 B
Go
package events
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
)
|
|
|
|
// EventToNull is an eventer type that does nothing.
|
|
// It is meant for unittests only
|
|
type EventToNull struct{}
|
|
|
|
// Write eats the event and always returns nil
|
|
func (e EventToNull) Write(ee Event) error {
|
|
return nil
|
|
}
|
|
|
|
// Read does nothing and returns an error.
|
|
func (e EventToNull) Read(ctx context.Context, options ReadOptions) error {
|
|
return errors.New("cannot read events with the \"none\" backend")
|
|
}
|
|
|
|
// newNullEventer returns a new null eventer. You should only do this for
|
|
// the purposes of internal libpod testing.
|
|
func newNullEventer() Eventer {
|
|
return EventToNull{}
|
|
}
|
|
|
|
// String returns a string representation of the logger
|
|
func (e EventToNull) String() string {
|
|
return "none"
|
|
}
|