mirror of https://github.com/docker/cli.git
Merge pull request #5370 from thaJeztah/fix_linting_issues
Fix linting issues in preparation of Go and GolangCI-lint update
This commit is contained in:
commit
3826f5ad73
|
@ -18,7 +18,7 @@ func NewManifestCommand(dockerCli command.Cli) *cobra.Command {
|
||||||
Long: manifestDescription,
|
Long: manifestDescription,
|
||||||
Args: cli.NoArgs,
|
Args: cli.NoArgs,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
fmt.Fprintf(dockerCli.Err(), "\n"+cmd.UsageString())
|
_, _ = fmt.Fprint(dockerCli.Err(), "\n"+cmd.UsageString())
|
||||||
},
|
},
|
||||||
Annotations: map[string]string{"experimentalCLI": ""},
|
Annotations: map[string]string{"experimentalCLI": ""},
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,10 +39,10 @@ func runRemove(ctx context.Context, dockerCli command.Cli, sids []string) error
|
||||||
errs = append(errs, err.Error())
|
errs = append(errs, err.Error())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
fmt.Fprintf(dockerCli.Out(), "%s\n", sid)
|
_, _ = fmt.Fprintf(dockerCli.Out(), "%s\n", sid)
|
||||||
}
|
}
|
||||||
if len(errs) > 0 {
|
if len(errs) > 0 {
|
||||||
return errors.Errorf(strings.Join(errs, "\n"))
|
return errors.New(strings.Join(errs, "\n"))
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ func runScale(ctx context.Context, dockerCli command.Cli, options *scaleOptions,
|
||||||
if len(errs) == 0 {
|
if len(errs) == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return errors.Errorf(strings.Join(errs, "\n"))
|
return errors.New(strings.Join(errs, "\n"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func runServiceScale(ctx context.Context, dockerCli command.Cli, serviceID string, scale uint64) error {
|
func runServiceScale(ctx context.Context, dockerCli command.Cli, serviceID string, scale uint64) error {
|
||||||
|
|
|
@ -48,7 +48,7 @@ func RunRemove(ctx context.Context, dockerCli command.Cli, opts options.Remove)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(services)+len(networks)+len(secrets)+len(configs) == 0 {
|
if len(services)+len(networks)+len(secrets)+len(configs) == 0 {
|
||||||
fmt.Fprintf(dockerCli.Err(), "Nothing found in stack: %s\n", namespace)
|
_, _ = fmt.Fprintf(dockerCli.Err(), "Nothing found in stack: %s\n", namespace)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ func RunRemove(ctx context.Context, dockerCli command.Cli, opts options.Remove)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(errs) > 0 {
|
if len(errs) > 0 {
|
||||||
return errors.Errorf(strings.Join(errs, "\n"))
|
return errors.New(strings.Join(errs, "\n"))
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -372,7 +372,7 @@ func prettyPrintServerInfo(streams command.Streams, info *dockerInfo) []error {
|
||||||
fprintln(output, " Product License:", info.ProductLicense)
|
fprintln(output, " Product License:", info.ProductLicense)
|
||||||
}
|
}
|
||||||
|
|
||||||
if info.DefaultAddressPools != nil && len(info.DefaultAddressPools) > 0 {
|
if len(info.DefaultAddressPools) > 0 {
|
||||||
fprintln(output, " Default Address Pools:")
|
fprintln(output, " Default Address Pools:")
|
||||||
for _, pool := range info.DefaultAddressPools {
|
for _, pool := range info.DefaultAddressPools {
|
||||||
fprintf(output, " Base: %s, Size: %d\n", pool.Base, pool.Size)
|
fprintf(output, " Base: %s, Size: %d\n", pool.Base, pool.Size)
|
||||||
|
|
|
@ -222,7 +222,7 @@ func ValidateOutputPath(path string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := ValidateOutputPathFileMode(fileInfo.Mode()); err != nil {
|
if err := ValidateOutputPathFileMode(fileInfo.Mode()); err != nil {
|
||||||
return errors.Wrapf(err, fmt.Sprintf("invalid output path: %q must be a directory or a regular file", path))
|
return errors.Wrapf(err, "invalid output path: %q must be a directory or a regular file", path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -30,52 +30,52 @@ func NoArgs(cmd *cobra.Command, args []string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// RequiresMinArgs returns an error if there is not at least min args
|
// RequiresMinArgs returns an error if there is not at least min args
|
||||||
func RequiresMinArgs(min int) cobra.PositionalArgs {
|
func RequiresMinArgs(minArgs int) cobra.PositionalArgs {
|
||||||
return func(cmd *cobra.Command, args []string) error {
|
return func(cmd *cobra.Command, args []string) error {
|
||||||
if len(args) >= min {
|
if len(args) >= minArgs {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return errors.Errorf(
|
return errors.Errorf(
|
||||||
"%[1]s: '%[2]s' requires at least %[3]d %[4]s\n\nUsage: %[5]s\n\nSee '%[2]s --help' for more information",
|
"%[1]s: '%[2]s' requires at least %[3]d %[4]s\n\nUsage: %[5]s\n\nSee '%[2]s --help' for more information",
|
||||||
binName(cmd),
|
binName(cmd),
|
||||||
cmd.CommandPath(),
|
cmd.CommandPath(),
|
||||||
min,
|
minArgs,
|
||||||
pluralize("argument", min),
|
pluralize("argument", minArgs),
|
||||||
cmd.UseLine(),
|
cmd.UseLine(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// RequiresMaxArgs returns an error if there is not at most max args
|
// RequiresMaxArgs returns an error if there is not at most max args
|
||||||
func RequiresMaxArgs(max int) cobra.PositionalArgs {
|
func RequiresMaxArgs(maxArgs int) cobra.PositionalArgs {
|
||||||
return func(cmd *cobra.Command, args []string) error {
|
return func(cmd *cobra.Command, args []string) error {
|
||||||
if len(args) <= max {
|
if len(args) <= maxArgs {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return errors.Errorf(
|
return errors.Errorf(
|
||||||
"%[1]s: '%[2]s' requires at most %[3]d %[4]s\n\nUsage: %[5]s\n\nSRun '%[2]s --help' for more information",
|
"%[1]s: '%[2]s' requires at most %[3]d %[4]s\n\nUsage: %[5]s\n\nSRun '%[2]s --help' for more information",
|
||||||
binName(cmd),
|
binName(cmd),
|
||||||
cmd.CommandPath(),
|
cmd.CommandPath(),
|
||||||
max,
|
maxArgs,
|
||||||
pluralize("argument", max),
|
pluralize("argument", maxArgs),
|
||||||
cmd.UseLine(),
|
cmd.UseLine(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// RequiresRangeArgs returns an error if there is not at least min args and at most max args
|
// RequiresRangeArgs returns an error if there is not at least min args and at most max args
|
||||||
func RequiresRangeArgs(min int, max int) cobra.PositionalArgs {
|
func RequiresRangeArgs(minArgs int, maxArgs int) cobra.PositionalArgs {
|
||||||
return func(cmd *cobra.Command, args []string) error {
|
return func(cmd *cobra.Command, args []string) error {
|
||||||
if len(args) >= min && len(args) <= max {
|
if len(args) >= minArgs && len(args) <= maxArgs {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return errors.Errorf(
|
return errors.Errorf(
|
||||||
"%[1]s: '%[2]s' requires at least %[3]d and at most %[4]d %[5]s\n\nUsage: %[6]s\n\nRun '%[2]s --help' for more information",
|
"%[1]s: '%[2]s' requires at least %[3]d and at most %[4]d %[5]s\n\nUsage: %[6]s\n\nRun '%[2]s --help' for more information",
|
||||||
binName(cmd),
|
binName(cmd),
|
||||||
cmd.CommandPath(),
|
cmd.CommandPath(),
|
||||||
min,
|
minArgs,
|
||||||
max,
|
maxArgs,
|
||||||
pluralize("argument", max),
|
pluralize("argument", maxArgs),
|
||||||
cmd.UseLine(),
|
cmd.UseLine(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -214,7 +214,7 @@ func TestPromptExitCode(t *testing.T) {
|
||||||
default:
|
default:
|
||||||
|
|
||||||
if err := bufioWriter.Flush(); err != nil {
|
if err := bufioWriter.Flush(); err != nil {
|
||||||
return poll.Continue(err.Error())
|
return poll.Continue("%v", err)
|
||||||
}
|
}
|
||||||
if strings.Contains(buf.String(), "[y/N]") {
|
if strings.Contains(buf.String(), "[y/N]") {
|
||||||
return poll.Success()
|
return poll.Success()
|
||||||
|
|
Loading…
Reference in New Issue