Merge pull request #6626 from thaJeztah/fix_perfsprint
fix perfsprint (concat-loop) linting
This commit is contained in:
@ -250,11 +250,12 @@ func commandAliases(cmd *cobra.Command) string {
|
||||
if cmd.HasParent() {
|
||||
parentPath = cmd.Parent().CommandPath() + " "
|
||||
}
|
||||
aliases := cmd.CommandPath()
|
||||
var aliases strings.Builder
|
||||
aliases.WriteString(cmd.CommandPath())
|
||||
for _, alias := range cmd.Aliases {
|
||||
aliases += ", " + parentPath + alias
|
||||
aliases.WriteString(", " + parentPath + alias)
|
||||
}
|
||||
return aliases
|
||||
return aliases.String()
|
||||
}
|
||||
|
||||
func topCommands(cmd *cobra.Command) []*cobra.Command {
|
||||
|
||||
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli/command"
|
||||
@ -61,7 +62,7 @@ func newPruneCommand(dockerCLI command.Cli) *cobra.Command {
|
||||
const warning = `WARNING! This will remove all stopped containers.
|
||||
Are you sure you want to continue?`
|
||||
|
||||
func runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions) (spaceReclaimed uint64, output string, err error) {
|
||||
func runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions) (spaceReclaimed uint64, output string, _ error) {
|
||||
pruneFilters := command.PruneFilters(dockerCli, options.filter.Value())
|
||||
|
||||
if !options.force {
|
||||
@ -81,15 +82,16 @@ func runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions)
|
||||
return 0, "", err
|
||||
}
|
||||
|
||||
var out strings.Builder
|
||||
if len(res.Report.ContainersDeleted) > 0 {
|
||||
output = "Deleted Containers:\n"
|
||||
out.WriteString("Deleted Containers:\n")
|
||||
for _, id := range res.Report.ContainersDeleted {
|
||||
output += id + "\n"
|
||||
out.WriteString(id + "\n")
|
||||
}
|
||||
spaceReclaimed = res.Report.SpaceReclaimed
|
||||
}
|
||||
|
||||
return spaceReclaimed, output, nil
|
||||
return spaceReclaimed, out.String(), nil
|
||||
}
|
||||
|
||||
type cancelledErr struct{ error }
|
||||
|
||||
@ -297,15 +297,15 @@ func printImageTree(outs command.Streams, view treeView) {
|
||||
}(),
|
||||
Color: &tui.ColorNone,
|
||||
DetailsValue: func(d *imageDetails) string {
|
||||
var out string
|
||||
var b strings.Builder
|
||||
for _, chip := range possibleChips {
|
||||
if chip.check(d) {
|
||||
out += chip.String(isTerm)
|
||||
b.WriteString(chip.String(isTerm))
|
||||
} else {
|
||||
out += chipPlaceholder.String(isTerm)
|
||||
b.WriteString(chipPlaceholder.String(isTerm))
|
||||
}
|
||||
}
|
||||
return out
|
||||
return b.String()
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -368,12 +368,14 @@ func adjustColumns(width uint, columns []imgColumn, images []topImage) []imgColu
|
||||
func generateLegend(out tui.Output, width uint) string {
|
||||
var legend string
|
||||
legend += out.Sprint(tui.InfoHeader)
|
||||
var legendSb371 strings.Builder
|
||||
for idx, chip := range allChips {
|
||||
legend += " " + out.Sprint(chip) + " " + chip.desc
|
||||
legendSb371.WriteString(" " + out.Sprint(chip) + " " + chip.desc)
|
||||
if idx < len(allChips)-1 {
|
||||
legend += " |"
|
||||
legendSb371.WriteString(" |")
|
||||
}
|
||||
}
|
||||
legend += legendSb371.String()
|
||||
|
||||
r := int(width) - tui.Width(legend)
|
||||
if r < 0 {
|
||||
|
||||
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli/command"
|
||||
@ -58,7 +59,7 @@ func newPruneCommand(dockerCLI command.Cli) *cobra.Command {
|
||||
const warning = `WARNING! This will remove all custom networks not used by at least one container.
|
||||
Are you sure you want to continue?`
|
||||
|
||||
func runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions) (output string, err error) {
|
||||
func runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions) (output string, _ error) {
|
||||
pruneFilters := command.PruneFilters(dockerCli, options.filter.Value())
|
||||
|
||||
if !options.force {
|
||||
@ -78,14 +79,15 @@ func runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions)
|
||||
return "", err
|
||||
}
|
||||
|
||||
var out strings.Builder
|
||||
if len(res.Report.NetworksDeleted) > 0 {
|
||||
output = "Deleted Networks:\n"
|
||||
out.WriteString("Deleted Networks:\n")
|
||||
for _, id := range res.Report.NetworksDeleted {
|
||||
output += id + "\n"
|
||||
out.WriteString(id + "\n")
|
||||
}
|
||||
}
|
||||
|
||||
return output, nil
|
||||
return out.String(), nil
|
||||
}
|
||||
|
||||
type cancelledErr struct{ error }
|
||||
|
||||
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/docker/cli/cli"
|
||||
"github.com/docker/cli/cli/command"
|
||||
@ -68,7 +69,7 @@ Are you sure you want to continue?`
|
||||
Are you sure you want to continue?`
|
||||
)
|
||||
|
||||
func runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions) (spaceReclaimed uint64, output string, err error) {
|
||||
func runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions) (spaceReclaimed uint64, output string, _ error) {
|
||||
pruneFilters := command.PruneFilters(dockerCli, options.filter.Value())
|
||||
|
||||
warning := unusedVolumesWarning
|
||||
@ -96,15 +97,16 @@ func runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions)
|
||||
return 0, "", err
|
||||
}
|
||||
|
||||
var out strings.Builder
|
||||
if len(res.Report.VolumesDeleted) > 0 {
|
||||
output = "Deleted Volumes:\n"
|
||||
out.WriteString("Deleted Volumes:\n")
|
||||
for _, id := range res.Report.VolumesDeleted {
|
||||
output += id + "\n"
|
||||
out.WriteString(id + "\n")
|
||||
}
|
||||
spaceReclaimed = res.Report.SpaceReclaimed
|
||||
}
|
||||
|
||||
return spaceReclaimed, output, nil
|
||||
return spaceReclaimed, out.String(), nil
|
||||
}
|
||||
|
||||
type invalidParamErr struct{ error }
|
||||
|
||||
Reference in New Issue
Block a user