1
0
mirror of https://github.com/docker/cli.git synced 2026-01-13 18:22:35 +03:00

Merge pull request #25983 from jhorwit2/jah/ps-refactor

Add -a option to service/node ps
This commit is contained in:
Vincent Demeester
2016-11-07 17:33:10 +01:00
committed by GitHub
2 changed files with 15 additions and 0 deletions

View File

@@ -17,6 +17,7 @@ import (
type psOptions struct {
nodeIDs []string
all bool
noResolve bool
noTrunc bool
filter opts.FilterOpt
@@ -43,6 +44,7 @@ func newPsCommand(dockerCli *command.DockerCli) *cobra.Command {
flags.BoolVar(&opts.noTrunc, "no-trunc", false, "Do not truncate output")
flags.BoolVar(&opts.noResolve, "no-resolve", false, "Do not map IDs to Names")
flags.VarP(&opts.filter, "filter", "f", "Filter output based on conditions provided")
flags.BoolVarP(&opts.all, "all", "a", false, "Show all tasks (default shows tasks that are or will be running)")
return cmd
}
@@ -72,6 +74,11 @@ func runPs(dockerCli *command.DockerCli, opts psOptions) error {
filter := opts.filter.Value()
filter.Add("node", node.ID)
if !opts.all && !filter.Include("desired-state") {
filter.Add("desired-state", string(swarm.TaskStateRunning))
filter.Add("desired-state", string(swarm.TaskStateAccepted))
}
nodeTasks, err := client.TaskList(ctx, types.TaskListOptions{Filters: filter})
if err != nil {
errs = append(errs, err.Error())