mirror of
https://github.com/containers/podman.git
synced 2025-08-06 03:19:52 +08:00
container: initialize results list
it solves: $ podman ps --format=json null Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
@ -449,10 +449,8 @@ func GetPsContainerOutput(r *libpod.Runtime, opts PsOptions, filters []string, m
|
|||||||
// PBatch performs batch operations on a container in parallel. It spawns the
|
// PBatch performs batch operations on a container in parallel. It spawns the
|
||||||
// number of workers relative to the number of parallel operations desired.
|
// number of workers relative to the number of parallel operations desired.
|
||||||
func PBatch(containers []*libpod.Container, workers int, opts PsOptions) []PsContainerOutput {
|
func PBatch(containers []*libpod.Container, workers int, opts PsOptions) []PsContainerOutput {
|
||||||
var (
|
var wg sync.WaitGroup
|
||||||
wg sync.WaitGroup
|
psResults := []PsContainerOutput{}
|
||||||
psResults []PsContainerOutput
|
|
||||||
)
|
|
||||||
|
|
||||||
// If the number of containers in question is less than the number of
|
// If the number of containers in question is less than the number of
|
||||||
// proposed parallel operations, we shouldnt spawn so many workers.
|
// proposed parallel operations, we shouldnt spawn so many workers.
|
||||||
|
@ -151,6 +151,13 @@ var _ = Describe("Podman ps", func() {
|
|||||||
Expect(len(result.OutputToStringArray())).Should(BeNumerically(">", 0))
|
Expect(len(result.OutputToStringArray())).Should(BeNumerically(">", 0))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("podman ps with no containers is valid json format", func() {
|
||||||
|
result := podmanTest.Podman([]string{"ps", "--format", "json"})
|
||||||
|
result.WaitWithDefaultTimeout()
|
||||||
|
Expect(result.ExitCode()).To(Equal(0))
|
||||||
|
Expect(result.IsJSONOutputValid()).To(BeTrue())
|
||||||
|
})
|
||||||
|
|
||||||
It("podman ps namespace flag with json format", func() {
|
It("podman ps namespace flag with json format", func() {
|
||||||
_, ec, _ := podmanTest.RunLsContainer("test1")
|
_, ec, _ := podmanTest.RunLsContainer("test1")
|
||||||
Expect(ec).To(Equal(0))
|
Expect(ec).To(Equal(0))
|
||||||
|
Reference in New Issue
Block a user