diff options
author | Brent Baude <bbaude@redhat.com> | 2020-03-27 13:21:51 -0500 |
---|---|---|
committer | Brent Baude <bbaude@redhat.com> | 2020-04-15 09:38:04 -0500 |
commit | 165aef7766953cd0c0589ffa1abc25022a905adb (patch) | |
tree | 4ac195c5290dbd6ea9fbfb5b1aaa53d169a00899 /pkg/domain/infra | |
parent | a756161e80cd32b705bb0dfe3ec4753f883ec929 (diff) | |
download | podman-165aef7766953cd0c0589ffa1abc25022a905adb.tar.gz podman-165aef7766953cd0c0589ffa1abc25022a905adb.tar.bz2 podman-165aef7766953cd0c0589ffa1abc25022a905adb.zip |
podmanv2 events
add the ability to monitor events
Signed-off-by: Brent Baude <bbaude@redhat.com>
Diffstat (limited to 'pkg/domain/infra')
-rw-r--r-- | pkg/domain/infra/abi/events.go | 18 | ||||
-rw-r--r-- | pkg/domain/infra/tunnel/events.go | 31 |
2 files changed, 49 insertions, 0 deletions
diff --git a/pkg/domain/infra/abi/events.go b/pkg/domain/infra/abi/events.go new file mode 100644 index 000000000..9540a5b96 --- /dev/null +++ b/pkg/domain/infra/abi/events.go @@ -0,0 +1,18 @@ +//+build ABISupport + +package abi + +import ( + "context" + + "github.com/containers/libpod/libpod/events" + "github.com/containers/libpod/pkg/domain/entities" + "github.com/sirupsen/logrus" +) + +func (ic *ContainerEngine) Events(ctx context.Context, opts entities.EventsOptions) error { + readOpts := events.ReadOptions{FromStart: opts.FromStart, Stream: opts.Stream, Filters: opts.Filter, EventChannel: opts.EventChan, Since: opts.Since, Until: opts.Until} + err := ic.Libpod.Events(readOpts) + logrus.Error(err) + return err +} diff --git a/pkg/domain/infra/tunnel/events.go b/pkg/domain/infra/tunnel/events.go new file mode 100644 index 000000000..46d88341a --- /dev/null +++ b/pkg/domain/infra/tunnel/events.go @@ -0,0 +1,31 @@ +package tunnel + +import ( + "context" + "strings" + + "github.com/containers/libpod/pkg/api/handlers" + "github.com/containers/libpod/pkg/bindings/system" + "github.com/containers/libpod/pkg/domain/entities" + "github.com/pkg/errors" +) + +func (ic *ContainerEngine) Events(ctx context.Context, opts entities.EventsOptions) error { + filters := make(map[string][]string) + if len(opts.Filter) > 0 { + for _, filter := range opts.Filter { + split := strings.Split(filter, "=") + if len(split) < 2 { + return errors.Errorf("invalid filter %q", filter) + } + filters[split[0]] = append(filters[split[0]], strings.Join(split[1:], "=")) + } + } + binChan := make(chan handlers.Event) + go func() { + for e := range binChan { + opts.EventChan <- e.ToLibpodEvent() + } + }() + return system.Events(ic.ClientCxt, binChan, nil, &opts.Since, &opts.Until, filters) +} |