Skip to content

Commit

Permalink
Merge pull request #9122 from Luap99/fix-9120
Browse files Browse the repository at this point in the history
Fix podman history --no-trunc for the CREATED BY field
  • Loading branch information
openshift-merge-robot authored Jan 27, 2021
2 parents 2102e26 + f79d68e commit 5c6175d
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 5c6175d

Please sign in to comment.