(ctx context.Context, dockerCli command.Cli, options psOptions)
| 49 | } |
| 50 | |
| 51 | func runPS(ctx context.Context, dockerCli command.Cli, options psOptions) error { |
| 52 | apiClient := dockerCli.Client() |
| 53 | |
| 54 | filter, notfound, err := createFilter(ctx, apiClient, options) |
| 55 | if err != nil { |
| 56 | return err |
| 57 | } |
| 58 | if err := updateNodeFilter(ctx, apiClient, filter); err != nil { |
| 59 | return err |
| 60 | } |
| 61 | |
| 62 | tasks, err := apiClient.TaskList(ctx, client.TaskListOptions{Filters: filter}) |
| 63 | if err != nil { |
| 64 | return err |
| 65 | } |
| 66 | |
| 67 | format := options.format |
| 68 | if len(format) == 0 { |
| 69 | format = task.DefaultFormat(dockerCli.ConfigFile(), options.quiet) |
| 70 | } |
| 71 | if options.quiet { |
| 72 | options.noTrunc = true |
| 73 | } |
| 74 | if err := task.Print(ctx, dockerCli, tasks, idresolver.New(apiClient, options.noResolve), !options.noTrunc, options.quiet, format); err != nil { |
| 75 | return err |
| 76 | } |
| 77 | if len(notfound) != 0 { |
| 78 | return errors.New(strings.Join(notfound, "\n")) |
| 79 | } |
| 80 | return nil |
| 81 | } |
| 82 | |
| 83 | func createFilter(ctx context.Context, apiClient client.APIClient, options psOptions) (client.Filters, []string, error) { |
| 84 | filter := options.filter.Value() |
searching dependent graphs…