Skip to content

Commit

Permalink
Fix podman history --no-trunc for the CREATED BY field
Browse files Browse the repository at this point in the history
Fixes containers#9120

Signed-off-by: Paul Holzinger <[email protected]>
  • Loading branch information
Paul Holzinger authored and mheon committed Jan 29, 2021
1 parent bb88db7 commit b4aa54c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/podman/images/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func (h historyReporter) Size() string {
}

func (h historyReporter) CreatedBy() string {
if len(h.ImageHistoryLayer.CreatedBy) > 45 {
if !opts.noTrunc && len(h.ImageHistoryLayer.CreatedBy) > 45 {
return h.ImageHistoryLayer.CreatedBy[:45-3] + "..."
}
return h.ImageHistoryLayer.CreatedBy
Expand Down
17 changes: 17 additions & 0 deletions test/e2e/history_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,23 @@ var _ = Describe("Podman history", func() {
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 0))

session = podmanTest.Podman([]string{"history", "--no-trunc", "--format", "{{.ID}}", ALPINE})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
lines := session.OutputToStringArray()
Expect(len(lines)).To(BeNumerically(">", 0))
// the image id must be 64 chars long
Expect(len(lines[0])).To(BeNumerically("==", 64))

session = podmanTest.Podman([]string{"history", "--no-trunc", "--format", "{{.CreatedBy}}", ALPINE})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
lines = session.OutputToStringArray()
Expect(len(lines)).To(BeNumerically(">", 0))
Expect(session.OutputToString()).ToNot(ContainSubstring("..."))
// the second line in the alpine history contains a command longer than 45 chars
Expect(len(lines[1])).To(BeNumerically(">", 45))
})

It("podman history with json flag", func() {
Expand Down

0 comments on commit b4aa54c

Please sign in to comment.