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