aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Holzinger <pholzing@redhat.com>2022-09-06 13:53:35 +0200
committerMatthew Heon <mheon@redhat.com>2022-09-06 15:11:22 -0400
commitda559869661b70e507e526435652ec54cc00d2f3 (patch)
tree09b213b13ecfa51a2becdccf5f6f8dd55cfb7a51
parentf7b68254f32a25c1fdefc383cd81480a836cff35 (diff)
downloadpodman-da559869661b70e507e526435652ec54cc00d2f3.tar.gz
podman-da559869661b70e507e526435652ec54cc00d2f3.tar.bz2
podman-da559869661b70e507e526435652ec54cc00d2f3.zip
fix podman events with custom format
podman events --format {{.ID}} was not working since the template was converted to a range but we only render each event individually. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
-rw-r--r--cmd/podman/system/events.go4
-rw-r--r--test/e2e/events_test.go7
2 files changed, 10 insertions, 1 deletions
diff --git a/cmd/podman/system/events.go b/cmd/podman/system/events.go
index b04668f86..3c6a35e83 100644
--- a/cmd/podman/system/events.go
+++ b/cmd/podman/system/events.go
@@ -85,7 +85,9 @@ func eventsCmd(cmd *cobra.Command, _ []string) error {
doJSON = report.IsJSON(eventFormat)
if !doJSON {
var err error
- rpt, err = report.New(os.Stdout, cmd.Name()).Parse(report.OriginUser, eventFormat)
+ // Use OriginUnknown so it does not add an extra range since it
+ // will only be called for each single element and not a slice.
+ rpt, err = report.New(os.Stdout, cmd.Name()).Parse(report.OriginUnknown, eventFormat)
if err != nil {
return err
}
diff --git a/test/e2e/events_test.go b/test/e2e/events_test.go
index 528fa143d..7de2c2b31 100644
--- a/test/e2e/events_test.go
+++ b/test/e2e/events_test.go
@@ -153,6 +153,13 @@ var _ = Describe("Podman events", func() {
event = events.Event{}
err = json.Unmarshal([]byte(jsonArr[0]), &event)
Expect(err).ToNot(HaveOccurred())
+
+ test = podmanTest.Podman([]string{"events", "--stream=false", "--filter=type=container", "--format", "ID: {{.ID}}"})
+ test.WaitWithDefaultTimeout()
+ Expect(test).To(Exit(0))
+ arr := test.OutputToStringArray()
+ Expect(len(arr)).To(BeNumerically(">", 1))
+ Expect(arr[0]).To(MatchRegexp("ID: [a-fA-F0-9]{64}"))
})
It("podman events --until future", func() {