Skip to content

Commit

Permalink
Merge pull request #202 from abhi/crictl_ps
Browse files Browse the repository at this point in the history
Adding --all option to crictl ps
  • Loading branch information
Random-Liu authored Nov 28, 2017
2 parents a9e38a4 + 205b68b commit adc934a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 10 additions & 1 deletion cmd/crictl/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,10 @@ var listContainersCommand = cli.Command{
Name: "output, o",
Usage: "Output format, One of: json|yaml|table",
},
cli.BoolFlag{
Name: "all, a",
Usage: "Show all containers",
},
},
Action: func(context *cli.Context) error {
if err := getRuntimeClient(context); err != nil {
Expand All @@ -289,6 +293,7 @@ var listContainersCommand = cli.Command{
labels: make(map[string]string),
quiet: context.Bool("quiet"),
output: context.String("output"),
all: context.Bool("all"),
}

for _, l := range context.StringSlice("label") {
Expand Down Expand Up @@ -498,8 +503,12 @@ func ListContainers(client pb.RuntimeServiceClient, opts listOptions) error {
if opts.podID != "" {
filter.PodSandboxId = opts.podID
}
st := &pb.ContainerStateValue{}
if !opts.all {
st.State = pb.ContainerState_CONTAINER_RUNNING
filter.State = st
}
if opts.state != "" {
st := &pb.ContainerStateValue{}
st.State = pb.ContainerState_CONTAINER_UNKNOWN
switch opts.state {
case "created":
Expand Down
2 changes: 2 additions & 0 deletions cmd/crictl/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ type listOptions struct {
quiet bool
// output format
output string
// all containers
all bool
}

type execOptions struct {
Expand Down

0 comments on commit adc934a

Please sign in to comment.