MCPcopy Index your code
hub / github.com/docker/cli / runPs

Function runPs

cli/command/node/ps.go:54–99  ·  view source on GitHub ↗
(ctx context.Context, dockerCLI command.Cli, options psOptions)

Source from the content-addressed store, hash-verified

52}
53
54func runPs(ctx context.Context, dockerCLI command.Cli, options psOptions) error {
55 apiClient := dockerCLI.Client()
56
57 var (
58 errs []error
59 tasks = client.TaskListResult{}
60 )
61
62 for _, nodeID := range options.nodeIDs {
63 nodeRef, err := Reference(ctx, apiClient, nodeID)
64 if err != nil {
65 errs = append(errs, err)
66 continue
67 }
68
69 res, err := apiClient.NodeInspect(ctx, nodeRef, client.NodeInspectOptions{})
70 if err != nil {
71 errs = append(errs, err)
72 continue
73 }
74
75 filter := options.filter.Value()
76 filter.Add("node", res.Node.ID)
77
78 nodeTasks, err := apiClient.TaskList(ctx, client.TaskListOptions{Filters: filter})
79 if err != nil {
80 errs = append(errs, err)
81 continue
82 }
83
84 tasks.Items = append(tasks.Items, nodeTasks.Items...)
85 }
86
87 format := options.format
88 if len(format) == 0 {
89 format = task.DefaultFormat(dockerCLI.ConfigFile(), options.quiet)
90 }
91
92 if len(errs) == 0 || len(tasks.Items) != 0 {
93 if err := task.Print(ctx, dockerCLI, tasks, idresolver.New(apiClient, options.noResolve), !options.noTrunc, options.quiet, format); err != nil {
94 errs = append(errs, err)
95 }
96 }
97
98 return errors.Join(errs...)
99}

Callers 1

newPsCommandFunction · 0.70

Calls 7

ReferenceFunction · 0.85
ClientMethod · 0.65
ValueMethod · 0.65
ConfigFileMethod · 0.65
NodeInspectMethod · 0.45
TaskListMethod · 0.45
PrintMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…