(ctx context.Context, dockerCLI command.Cli, options listOptions)
| 42 | } |
| 43 | |
| 44 | func runList(ctx context.Context, dockerCLI command.Cli, options listOptions) error { |
| 45 | apiClient := dockerCLI.Client() |
| 46 | res, err := apiClient.ServiceList(ctx, client.ServiceListOptions{ |
| 47 | Filters: options.filter.Value(), |
| 48 | // When not running "quiet", also get service status (number of running |
| 49 | // and desired tasks). Note that this is only supported on API v1.41 and |
| 50 | // up; older API versions ignore this option, and we will have to collect |
| 51 | // the information manually below. |
| 52 | Status: !options.quiet, |
| 53 | }) |
| 54 | if err != nil { |
| 55 | return err |
| 56 | } |
| 57 | |
| 58 | format := options.format |
| 59 | if len(format) == 0 { |
| 60 | if len(dockerCLI.ConfigFile().ServicesFormat) > 0 && !options.quiet { |
| 61 | format = dockerCLI.ConfigFile().ServicesFormat |
| 62 | } else { |
| 63 | format = formatter.TableFormatKey |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | servicesCtx := formatter.Context{ |
| 68 | Output: dockerCLI.Out(), |
| 69 | Format: NewListFormat(format, options.quiet), |
| 70 | } |
| 71 | return ListFormatWrite(servicesCtx, res) |
| 72 | } |
no test coverage detected
searching dependent graphs…