Skip to content

Commit 3a888d4

Browse files
committed
Adding --all option to crictl ps
Signed-off-by: abhi <[email protected]>
1 parent a9e38a4 commit 3a888d4

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

cmd/crictl/container.go

+10
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,10 @@ var listContainersCommand = cli.Command{
275275
Name: "output, o",
276276
Usage: "Output format, One of: json|yaml|table",
277277
},
278+
cli.BoolFlag{
279+
Name: "all, a",
280+
Usage: "Show all containers",
281+
},
278282
},
279283
Action: func(context *cli.Context) error {
280284
if err := getRuntimeClient(context); err != nil {
@@ -289,6 +293,7 @@ var listContainersCommand = cli.Command{
289293
labels: make(map[string]string),
290294
quiet: context.Bool("quiet"),
291295
output: context.String("output"),
296+
all: context.Bool("all"),
292297
}
293298

294299
for _, l := range context.StringSlice("label") {
@@ -498,6 +503,11 @@ func ListContainers(client pb.RuntimeServiceClient, opts listOptions) error {
498503
if opts.podID != "" {
499504
filter.PodSandboxId = opts.podID
500505
}
506+
if !opts.all {
507+
st := &pb.ContainerStateValue{}
508+
st.State = pb.ContainerState_CONTAINER_RUNNING
509+
filter.State = st
510+
}
501511
if opts.state != "" {
502512
st := &pb.ContainerStateValue{}
503513
st.State = pb.ContainerState_CONTAINER_UNKNOWN

cmd/crictl/util.go

+2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ type listOptions struct {
5656
quiet bool
5757
// output format
5858
output string
59+
// all containers
60+
all bool
5961
}
6062

6163
type execOptions struct {

0 commit comments

Comments
 (0)