(ctx context.Context, dockerCLI command.Cli, options listOptions)
| 46 | } |
| 47 | |
| 48 | func runList(ctx context.Context, dockerCLI command.Cli, options listOptions) error { |
| 49 | apiClient := dockerCLI.Client() |
| 50 | res, err := apiClient.NetworkList(ctx, client.NetworkListOptions{Filters: options.filter.Value()}) |
| 51 | if err != nil { |
| 52 | return err |
| 53 | } |
| 54 | |
| 55 | format := options.format |
| 56 | if len(format) == 0 { |
| 57 | if len(dockerCLI.ConfigFile().NetworksFormat) > 0 && !options.quiet { |
| 58 | format = dockerCLI.ConfigFile().NetworksFormat |
| 59 | } else { |
| 60 | format = formatter.TableFormatKey |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | sort.Slice(res.Items, func(i, j int) bool { |
| 65 | return sortorder.NaturalLess(res.Items[i].Name, res.Items[j].Name) |
| 66 | }) |
| 67 | |
| 68 | networksCtx := formatter.Context{ |
| 69 | Output: dockerCLI.Out(), |
| 70 | Format: newFormat(format, options.quiet), |
| 71 | Trunc: !options.noTrunc, |
| 72 | } |
| 73 | return formatWrite(networksCtx, res) |
| 74 | } |
no test coverage detected
searching dependent graphs…