summaryrefslogtreecommitdiff
path: root/libpod/events/events.go
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2020-10-21 11:59:35 -0500
committerbaude <bbaude@redhat.com>2020-10-23 12:07:34 -0500
commitc593e49701b3a4bb48050f3d8829f2fe6ac457ef (patch)
treef69648182082c37d4416efdb5405a9431984463c /libpod/events/events.go
parent51fa8ded9ffb7924288a2728ce92af7f6cc66d34 (diff)
downloadpodman-c593e49701b3a4bb48050f3d8829f2fe6ac457ef.tar.gz
podman-c593e49701b3a4bb48050f3d8829f2fe6ac457ef.tar.bz2
podman-c593e49701b3a4bb48050f3d8829f2fe6ac457ef.zip
filter events by labels
adding the ability to filter evens by the container labels. this requires that container labels be added to the events data being recorded and subsequently read. Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'libpod/events/events.go')
-rw-r--r--libpod/events/events.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/libpod/events/events.go b/libpod/events/events.go
index 722c9595e..42939d64c 100644
--- a/libpod/events/events.go
+++ b/libpod/events/events.go
@@ -69,7 +69,14 @@ func (e *Event) ToHumanReadable() string {
var humanFormat string
switch e.Type {
case Container, Pod:
- humanFormat = fmt.Sprintf("%s %s %s %s (image=%s, name=%s)", e.Time, e.Type, e.Status, e.ID, e.Image, e.Name)
+ humanFormat = fmt.Sprintf("%s %s %s %s (image=%s, name=%s", e.Time, e.Type, e.Status, e.ID, e.Image, e.Name)
+ // check if the container has labels and add it to the output
+ if len(e.Attributes) > 0 {
+ for k, v := range e.Attributes {
+ humanFormat += fmt.Sprintf(", %s=%s", k, v)
+ }
+ }
+ humanFormat += ")"
case Image:
humanFormat = fmt.Sprintf("%s %s %s %s %s", e.Time, e.Type, e.Status, e.ID, e.Name)
case System: