cli/command: fix n-constant format string in call (govet)

cli/command/utils.go:225:29: printf: non-constant format string in call to github.com/pkg/errors.Wrapf (govet)
                return errors.Wrapf(err, fmt.Sprintf("invalid output path: %q must be a directory or a regular file", path))
                                         ^
    cli/command/manifest/cmd.go:21:33: printf: non-constant format string in call to fmt.Fprintf (govet)
                fmt.Fprintf(dockerCli.Err(), "\n"+cmd.UsageString())
                                             ^
    cli/command/service/remove.go:45:24: printf: non-constant format string in call to github.com/pkg/errors.Errorf (govet)
            return errors.Errorf(strings.Join(errs, "\n"))
                                 ^
    cli/command/service/scale.go:93:23: printf: non-constant format string in call to github.com/pkg/errors.Errorf (govet)
        return errors.Errorf(strings.Join(errs, "\n"))
                             ^
    cli/command/stack/swarm/remove.go:74:24: printf: non-constant format string in call to github.com/pkg/errors.Errorf (govet)
            return errors.Errorf(strings.Join(errs, "\n"))
                                 ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit f101f07a7b)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2024-08-26 13:52:49 +02:00
parent d8af7812b5
commit 002cfcde85
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
5 changed files with 7 additions and 7 deletions

View File

@ -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": ""},
} }

View File

@ -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
} }

View File

@ -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 {

View File

@ -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
} }

View File

@ -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