Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding --all option to crictl ps #202

Merged
merged 1 commit into from
Nov 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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