mirror of
https://github.com/containers/podman.git
synced 2025-10-11 16:26:00 +08:00
Output headers for volume ls when empty
To have consistency with other podman commands like `ps` and `images`, `volume ls` should output its headers even when there are no volumes. Fixes: https://github.com/containers/podman/issues/25911 Signed-off-by: Brent Baude <bbaude@redhat.com>
This commit is contained in:
@ -80,11 +80,8 @@ func list(cmd *cobra.Command, args []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
switch {
|
||||
case report.IsJSON(cliOpts.Format):
|
||||
if report.IsJSON(cliOpts.Format) {
|
||||
return outputJSON(responses)
|
||||
case len(responses) < 1:
|
||||
return nil
|
||||
}
|
||||
return outputTemplate(cmd, responses)
|
||||
}
|
||||
|
@ -377,7 +377,7 @@ var _ = Describe("Podman prune", func() {
|
||||
session = podmanTest.Podman([]string{"volume", "ls"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(ExitCleanly())
|
||||
Expect(session.OutputToStringArray()).To(BeEmpty())
|
||||
Expect(session.OutputToStringArray()).To(HaveLen(1))
|
||||
|
||||
// One Pod should not be pruned as it was running
|
||||
Expect(podmanTest.NumberOfPods()).To(Equal(1))
|
||||
|
@ -55,7 +55,7 @@ var _ = Describe("podman system reset", Serial, func() {
|
||||
session = podmanTest.Podman([]string{"volume", "ls"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(ExitCleanly())
|
||||
Expect(session.OutputToStringArray()).To(BeEmpty())
|
||||
Expect(session.OutputToStringArray()).To(HaveLen(1))
|
||||
|
||||
session = podmanTest.Podman([]string{"container", "ls", "-q"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
|
@ -17,6 +17,13 @@ var _ = Describe("Podman volume ls", func() {
|
||||
})
|
||||
|
||||
It("podman ls volume", func() {
|
||||
// https://github.com/containers/podman/issues/25911
|
||||
// Output header for volume ls even when empty
|
||||
empty := podmanTest.PodmanExitCleanly("volume", "ls")
|
||||
Expect(empty.OutputToString()).To(ContainSubstring("DRIVER"))
|
||||
Expect(empty.OutputToString()).To(ContainSubstring("VOLUME NAME"))
|
||||
Expect(empty.ErrorToStringArray()).To(HaveLen(1))
|
||||
|
||||
session := podmanTest.Podman([]string{"volume", "create", "myvol"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(ExitCleanly())
|
||||
@ -94,7 +101,6 @@ var _ = Describe("Podman volume ls", func() {
|
||||
session = podmanTest.Podman([]string{"volume", "ls", "--filter", "label=foo=foo"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(ExitCleanly())
|
||||
Expect(session.OutputToStringArray()).To(BeEmpty())
|
||||
|
||||
session = podmanTest.Podman([]string{"volume", "ls", "--filter", "label=foo=bar"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
@ -105,7 +111,6 @@ var _ = Describe("Podman volume ls", func() {
|
||||
session = podmanTest.Podman([]string{"volume", "ls", "--filter", "label=foo=baz"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(ExitCleanly())
|
||||
Expect(session.OutputToStringArray()).To(BeEmpty())
|
||||
})
|
||||
|
||||
It("podman ls volume with --filter until flag", func() {
|
||||
@ -121,7 +126,6 @@ var _ = Describe("Podman volume ls", func() {
|
||||
session = podmanTest.Podman([]string{"volume", "ls", "--filter", "until=50000"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(ExitCleanly())
|
||||
Expect(session.OutputToStringArray()).To(BeEmpty())
|
||||
})
|
||||
|
||||
It("podman volume ls with --filter dangling", func() {
|
||||
@ -171,7 +175,6 @@ var _ = Describe("Podman volume ls", func() {
|
||||
session = podmanTest.Podman([]string{"volume", "ls", "--filter", "name=volumex"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(ExitCleanly())
|
||||
Expect(session.OutputToStringArray()).To(BeEmpty())
|
||||
|
||||
session = podmanTest.Podman([]string{"volume", "ls", "--filter", "name=volume1"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
|
@ -68,7 +68,7 @@ var _ = Describe("Podman volume prune", func() {
|
||||
session = podmanTest.Podman([]string{"volume", "ls"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(ExitCleanly())
|
||||
Expect(session.OutputToStringArray()).To(BeEmpty())
|
||||
Expect(session.OutputToStringArray()).To(HaveLen(1))
|
||||
})
|
||||
|
||||
It("podman prune volume --filter", func() {
|
||||
@ -163,7 +163,7 @@ var _ = Describe("Podman volume prune", func() {
|
||||
session = podmanTest.Podman([]string{"volume", "ls"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(ExitCleanly())
|
||||
Expect(session.OutputToStringArray()).To(BeEmpty())
|
||||
Expect(session.OutputToStringArray()).To(HaveLen(1))
|
||||
})
|
||||
|
||||
It("podman volume prune --filter since/after", func() {
|
||||
|
@ -28,7 +28,7 @@ var _ = Describe("Podman volume rm", func() {
|
||||
session = podmanTest.Podman([]string{"volume", "ls"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(ExitCleanly())
|
||||
Expect(session.OutputToStringArray()).To(BeEmpty())
|
||||
Expect(session.OutputToStringArray()).To(HaveLen(1))
|
||||
})
|
||||
|
||||
It("podman volume rm with --force flag", func() {
|
||||
@ -48,7 +48,7 @@ var _ = Describe("Podman volume rm", func() {
|
||||
session = podmanTest.Podman([]string{"volume", "ls"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(ExitCleanly())
|
||||
Expect(session.OutputToStringArray()).To(BeEmpty())
|
||||
Expect(session.OutputToStringArray()).To(HaveLen(1))
|
||||
})
|
||||
|
||||
It("podman volume remove bogus", func() {
|
||||
@ -73,7 +73,7 @@ var _ = Describe("Podman volume rm", func() {
|
||||
session = podmanTest.Podman([]string{"volume", "ls"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(ExitCleanly())
|
||||
Expect(session.OutputToStringArray()).To(BeEmpty())
|
||||
Expect(session.OutputToStringArray()).To(HaveLen(1))
|
||||
})
|
||||
|
||||
It("podman volume rm by partial name", func() {
|
||||
@ -88,7 +88,7 @@ var _ = Describe("Podman volume rm", func() {
|
||||
session = podmanTest.Podman([]string{"volume", "ls"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(ExitCleanly())
|
||||
Expect(session.OutputToStringArray()).To(BeEmpty())
|
||||
Expect(session.OutputToStringArray()).To(HaveLen(1))
|
||||
})
|
||||
|
||||
It("podman volume rm by nonunique partial name", func() {
|
||||
|
Reference in New Issue
Block a user