(ctx context.Context, dockerCli command.Cli, backendOptions *BackendOptions, opts topOptions, services []string)
| 56 | ) |
| 57 | |
| 58 | func runTop(ctx context.Context, dockerCli command.Cli, backendOptions *BackendOptions, opts topOptions, services []string) error { |
| 59 | projectName, err := opts.toProjectName(ctx, dockerCli) |
| 60 | if err != nil { |
| 61 | return err |
| 62 | } |
| 63 | |
| 64 | backend, err := compose.NewComposeService(dockerCli, backendOptions.Options...) |
| 65 | if err != nil { |
| 66 | return err |
| 67 | } |
| 68 | containers, err := backend.Top(ctx, projectName, services) |
| 69 | if err != nil { |
| 70 | return err |
| 71 | } |
| 72 | |
| 73 | sort.Slice(containers, func(i, j int) bool { |
| 74 | return containers[i].Name < containers[j].Name |
| 75 | }) |
| 76 | |
| 77 | header, entries := collectTop(containers) |
| 78 | return topPrint(dockerCli.Out(), header, entries) |
| 79 | } |
| 80 | |
| 81 | func collectTop(containers []api.ContainerProcSummary) (topHeader, []topEntries) { |
| 82 | // map column name to its header (should keep working if backend.Top returns |
no test coverage detected