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

Function runList

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

Source from the content-addressed store, hash-verified

52}
53
54func runList(ctx context.Context, dockerCLI command.Cli, options listOptions) error {
55 apiClient := dockerCLI.Client()
56 res, err := apiClient.VolumeList(ctx, client.VolumeListOptions{Filters: options.filter.Value()})
57 if err != nil {
58 return err
59 }
60
61 format := options.format
62 if len(format) == 0 && !options.cluster {
63 if len(dockerCLI.ConfigFile().VolumesFormat) > 0 && !options.quiet {
64 format = dockerCLI.ConfigFile().VolumesFormat
65 } else {
66 format = formatter.TableFormatKey
67 }
68 } else if options.cluster {
69 // TODO(dperny): write server-side filter for cluster volumes. For this
70 // proof of concept, we'll just filter out non-cluster volumes here
71
72 // trick for filtering in place
73 n := 0
74 for _, vol := range res.Items {
75 if vol.ClusterVolume != nil {
76 res.Items[n] = vol
77 n++
78 }
79 }
80 res.Items = res.Items[:n]
81 if !options.quiet {
82 format = clusterTableFormat
83 } else {
84 format = formatter.TableFormatKey
85 }
86 }
87
88 sort.Slice(res.Items, func(i, j int) bool {
89 return sortorder.NaturalLess(res.Items[i].Name, res.Items[j].Name)
90 })
91
92 volumeCtx := formatter.Context{
93 Output: dockerCLI.Out(),
94 Format: formatter.NewVolumeFormat(format, options.quiet),
95 }
96 return formatter.VolumeWrite(volumeCtx, res.Items)
97}

Callers 1

newListCommandFunction · 0.70

Calls 5

ClientMethod · 0.65
ValueMethod · 0.65
ConfigFileMethod · 0.65
OutMethod · 0.65
VolumeListMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…