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

Function runPS

cli/command/service/ps.go:51–81  ·  view source on GitHub ↗
(ctx context.Context, dockerCli command.Cli, options psOptions)

Source from the content-addressed store, hash-verified

49}
50
51func 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
83func createFilter(ctx context.Context, apiClient client.APIClient, options psOptions) (client.Filters, []string, error) {
84 filter := options.filter.Value()

Callers 3

newPsCommandFunction · 0.70
TestRunPSWarnsOnNotFoundFunction · 0.70
TestRunPSQuietFunction · 0.70

Calls 6

createFilterFunction · 0.85
updateNodeFilterFunction · 0.85
ClientMethod · 0.65
ConfigFileMethod · 0.65
TaskListMethod · 0.45
PrintMethod · 0.45

Tested by 2

TestRunPSWarnsOnNotFoundFunction · 0.56
TestRunPSQuietFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…