cli/command/stack: minor cleanups: use Println, rename vars
- use Println to print newline instead of custom format - use dockerCLI with Go's standard camelCase casing. - suppress some errors to make my IDE and linters happier Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@ -52,28 +52,28 @@ func RunServices(ctx context.Context, dockerCli command.Cli, opts options.Servic
|
||||
return formatWrite(dockerCli, services, opts)
|
||||
}
|
||||
|
||||
func formatWrite(dockerCli command.Cli, services []swarmtypes.Service, opts options.Services) error {
|
||||
func formatWrite(dockerCLI command.Cli, services []swarmtypes.Service, opts options.Services) error {
|
||||
// if no services in the stack, print message and exit 0
|
||||
if len(services) == 0 {
|
||||
_, _ = fmt.Fprintf(dockerCli.Err(), "Nothing found in stack: %s\n", opts.Namespace)
|
||||
_, _ = fmt.Fprintln(dockerCLI.Err(), "Nothing found in stack:", opts.Namespace)
|
||||
return nil
|
||||
}
|
||||
sort.Slice(services, func(i, j int) bool {
|
||||
return sortorder.NaturalLess(services[i].Spec.Name, services[j].Spec.Name)
|
||||
})
|
||||
|
||||
format := opts.Format
|
||||
if len(format) == 0 {
|
||||
if len(dockerCli.ConfigFile().ServicesFormat) > 0 && !opts.Quiet {
|
||||
format = dockerCli.ConfigFile().ServicesFormat
|
||||
f := opts.Format
|
||||
if len(f) == 0 {
|
||||
if len(dockerCLI.ConfigFile().ServicesFormat) > 0 && !opts.Quiet {
|
||||
f = dockerCLI.ConfigFile().ServicesFormat
|
||||
} else {
|
||||
format = formatter.TableFormatKey
|
||||
f = formatter.TableFormatKey
|
||||
}
|
||||
}
|
||||
|
||||
servicesCtx := formatter.Context{
|
||||
Output: dockerCli.Out(),
|
||||
Format: service.NewListFormat(format, opts.Quiet),
|
||||
Output: dockerCLI.Out(),
|
||||
Format: service.NewListFormat(f, opts.Quiet),
|
||||
}
|
||||
return service.ListFormatWrite(servicesCtx, services)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user