Slight modification to kpod ps based on QE feedback

QE noticed that kpod ps --last 0 was returning the running containers
Fixed that problem so that it returns nothing

Signed-off-by: umohnani8 <umohnani@redhat.com>
This commit is contained in:
umohnani8 2017-09-06 15:40:20 -04:00
parent f9387aca28
commit 45c7100253
2 changed files with 3 additions and 3 deletions

View File

@ -85,6 +85,7 @@ var (
cli.IntFlag{
Name: "last, n",
Usage: "Print the n last created containers (all states)",
Value: -1,
},
cli.BoolFlag{
Name: "latest, l",
@ -149,7 +150,7 @@ func psCmd(c *cli.Context) error {
// all, latest, and last are mutually exclusive. Only one flag can be used at a time
exclusiveOpts := 0
if opts.last > 0 {
if opts.last >= 0 {
exclusiveOpts++
}
if opts.latest {
@ -225,7 +226,7 @@ func (p *psTemplateParams) headerMap() map[string]string {
// getContainers gets the containers that match the flags given
func getContainers(containers []*libkpod.ContainerData, opts psOptions) []*libkpod.ContainerData {
var containersOutput []*libkpod.ContainerData
if opts.last > 0 && opts.last < len(containers) {
if opts.last >= 0 && opts.last < len(containers) {
for i := 0; i < opts.last; i++ {
containersOutput = append(containersOutput, containers[i])
}

View File

@ -57,7 +57,6 @@ Valid placeholders for the Go template are listed below:
| .Size | Size of container |
| .Names | Name of container |
| .Labels | All the labels assigned to the container |
| .Label | Value of the specific label provided by the user |
| .Mounts | Volumes mounted in the container |