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

Function runList

cli/command/node/list.go:45–80  ·  view source on GitHub ↗
(ctx context.Context, dockerCLI command.Cli, options listOptions)

Source from the content-addressed store, hash-verified

43}
44
45func runList(ctx context.Context, dockerCLI command.Cli, options listOptions) error {
46 apiClient := dockerCLI.Client()
47
48 res, err := apiClient.NodeList(ctx, client.NodeListOptions{
49 Filters: options.filter.Value(),
50 })
51 if err != nil {
52 return err
53 }
54
55 var info client.SystemInfoResult
56 if len(res.Items) > 0 && !options.quiet {
57 // only non-empty nodes and not quiet, should we call /info api
58 info, err = apiClient.Info(ctx, client.InfoOptions{})
59 if err != nil {
60 return err
61 }
62 }
63
64 format := options.format
65 if len(format) == 0 {
66 format = formatter.TableFormatKey
67 if len(dockerCLI.ConfigFile().NodesFormat) > 0 && !options.quiet {
68 format = dockerCLI.ConfigFile().NodesFormat
69 }
70 }
71
72 nodesCtx := formatter.Context{
73 Output: dockerCLI.Out(),
74 Format: newFormat(format, options.quiet),
75 }
76 sort.Slice(res.Items, func(i, j int) bool {
77 return sortorder.NaturalLess(res.Items[i].Description.Hostname, res.Items[j].Description.Hostname)
78 })
79 return formatWrite(nodesCtx, res, info)
80}

Callers 1

newListCommandFunction · 0.70

Calls 8

newFormatFunction · 0.70
formatWriteFunction · 0.70
ClientMethod · 0.65
ValueMethod · 0.65
ConfigFileMethod · 0.65
OutMethod · 0.65
NodeListMethod · 0.45
InfoMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…