Skip to content

Commit

Permalink
fix podman events with custom format
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Luap99 committed Sep 6, 2022
1 parent 098c071 commit d22aeee
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cmd/podman/system/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
7 changes: 7 additions & 0 deletions test/e2e/events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit d22aeee

Please sign in to comment.