diff --git a/cli/command/service/create.go b/cli/command/service/create.go index b1bed66195..ec3cf11953 100644 --- a/cli/command/service/create.go +++ b/cli/command/service/create.go @@ -78,8 +78,8 @@ func newCreateCommand(dockerCli command.Cli) *cobra.Command { return cmd } -func runCreate(ctx context.Context, dockerCli command.Cli, flags *pflag.FlagSet, opts *serviceOptions) error { - apiClient := dockerCli.Client() +func runCreate(ctx context.Context, dockerCLI command.Cli, flags *pflag.FlagSet, opts *serviceOptions) error { + apiClient := dockerCLI.Client() createOpts := types.ServiceCreateOptions{} service, err := opts.ToService(ctx, apiClient, flags) @@ -87,7 +87,7 @@ func runCreate(ctx context.Context, dockerCli command.Cli, flags *pflag.FlagSet, return err } - if err = validateAPIVersion(service, dockerCli.Client().ClientVersion()); err != nil { + if err = validateAPIVersion(service, dockerCLI.Client().ClientVersion()); err != nil { return err } @@ -105,14 +105,14 @@ func runCreate(ctx context.Context, dockerCli command.Cli, flags *pflag.FlagSet, return err } - if err := resolveServiceImageDigestContentTrust(dockerCli, &service); err != nil { + if err := resolveServiceImageDigestContentTrust(dockerCLI, &service); err != nil { return err } // only send auth if flag was set if opts.registryAuth { // Retrieve encoded auth token from the image reference - encodedAuth, err := command.RetrieveAuthTokenFromImage(dockerCli.ConfigFile(), opts.image) + encodedAuth, err := command.RetrieveAuthTokenFromImage(dockerCLI.ConfigFile(), opts.image) if err != nil { return err } @@ -130,16 +130,16 @@ func runCreate(ctx context.Context, dockerCli command.Cli, flags *pflag.FlagSet, } for _, warning := range response.Warnings { - fmt.Fprintln(dockerCli.Err(), warning) + _, _ = fmt.Fprintln(dockerCLI.Err(), warning) } - fmt.Fprintf(dockerCli.Out(), "%s\n", response.ID) + _, _ = fmt.Fprintln(dockerCLI.Out(), response.ID) if opts.detach || versions.LessThan(apiClient.ClientVersion(), "1.29") { return nil } - return WaitOnService(ctx, dockerCli, response.ID, opts.quiet) + return WaitOnService(ctx, dockerCLI, response.ID, opts.quiet) } // setConfigs does double duty: it both sets the ConfigReferences of the diff --git a/cli/command/service/remove.go b/cli/command/service/remove.go index efbd5f9ad0..a191aa97bf 100644 --- a/cli/command/service/remove.go +++ b/cli/command/service/remove.go @@ -29,17 +29,17 @@ func newRemoveCommand(dockerCli command.Cli) *cobra.Command { return cmd } -func runRemove(ctx context.Context, dockerCli command.Cli, sids []string) error { - client := dockerCli.Client() +func runRemove(ctx context.Context, dockerCLI command.Cli, serviceIDs []string) error { + apiClient := dockerCLI.Client() var errs []string - for _, sid := range sids { - err := client.ServiceRemove(ctx, sid) + for _, id := range serviceIDs { + err := apiClient.ServiceRemove(ctx, id) if err != nil { errs = append(errs, err.Error()) continue } - _, _ = fmt.Fprintf(dockerCli.Out(), "%s\n", sid) + _, _ = fmt.Fprintln(dockerCLI.Out(), id) } if len(errs) > 0 { return errors.New(strings.Join(errs, "\n")) diff --git a/cli/command/service/rollback.go b/cli/command/service/rollback.go index 06be65bb90..f7efa2d498 100644 --- a/cli/command/service/rollback.go +++ b/cli/command/service/rollback.go @@ -34,8 +34,8 @@ func newRollbackCommand(dockerCli command.Cli) *cobra.Command { return cmd } -func runRollback(ctx context.Context, dockerCli command.Cli, options *serviceOptions, serviceID string) error { - apiClient := dockerCli.Client() +func runRollback(ctx context.Context, dockerCLI command.Cli, options *serviceOptions, serviceID string) error { + apiClient := dockerCLI.Client() service, _, err := apiClient.ServiceInspectWithRaw(ctx, serviceID, types.ServiceInspectOptions{}) if err != nil { @@ -53,14 +53,14 @@ func runRollback(ctx context.Context, dockerCli command.Cli, options *serviceOpt } for _, warning := range response.Warnings { - fmt.Fprintln(dockerCli.Err(), warning) + _, _ = fmt.Fprintln(dockerCLI.Err(), warning) } - fmt.Fprintf(dockerCli.Out(), "%s\n", serviceID) + _, _ = fmt.Fprintln(dockerCLI.Out(), serviceID) if options.detach || versions.LessThan(apiClient.ClientVersion(), "1.29") { return nil } - return WaitOnService(ctx, dockerCli, serviceID, options.quiet) + return WaitOnService(ctx, dockerCLI, serviceID, options.quiet) } diff --git a/cli/command/service/scale.go b/cli/command/service/scale.go index 688a3ff2d0..7d34359b6e 100644 --- a/cli/command/service/scale.go +++ b/cli/command/service/scale.go @@ -117,9 +117,9 @@ func runServiceScale(ctx context.Context, dockerCli command.Cli, serviceID strin } for _, warning := range response.Warnings { - fmt.Fprintln(dockerCli.Err(), warning) + _, _ = fmt.Fprintln(dockerCli.Err(), warning) } - fmt.Fprintf(dockerCli.Out(), "%s scaled to %d\n", serviceID, scale) + _, _ = fmt.Fprintf(dockerCli.Out(), "%s scaled to %d\n", serviceID, scale) return nil } diff --git a/cli/command/service/trust.go b/cli/command/service/trust.go index 3aec19002e..cb32534d37 100644 --- a/cli/command/service/trust.go +++ b/cli/command/service/trust.go @@ -73,7 +73,7 @@ func trustedResolveDigest(cli command.Cli, ref reference.NamedTagged) (reference return nil, trust.NotaryError(repoInfo.Name.Name(), errors.Errorf("No trust data for %s", reference.FamiliarString(ref))) } - logrus.Debugf("retrieving target for %s role\n", t.Role) + logrus.Debugf("retrieving target for %s role", t.Role) h, ok := t.Hashes["sha256"] if !ok { return nil, errors.New("no valid hash, expecting sha256") diff --git a/cli/command/service/update.go b/cli/command/service/update.go index 811dcf22b3..a9c52f5f54 100644 --- a/cli/command/service/update.go +++ b/cli/command/service/update.go @@ -129,8 +129,8 @@ func newListOptsVarWithValidator(validator opts.ValidatorFctType) *opts.ListOpts } //nolint:gocyclo -func runUpdate(ctx context.Context, dockerCli command.Cli, flags *pflag.FlagSet, options *serviceOptions, serviceID string) error { - apiClient := dockerCli.Client() +func runUpdate(ctx context.Context, dockerCLI command.Cli, flags *pflag.FlagSet, options *serviceOptions, serviceID string) error { + apiClient := dockerCLI.Client() service, _, err := apiClient.ServiceInspectWithRaw(ctx, serviceID, types.ServiceInspectOptions{}) if err != nil { @@ -188,7 +188,7 @@ func runUpdate(ctx context.Context, dockerCli command.Cli, flags *pflag.FlagSet, } if flags.Changed("image") { - if err := resolveServiceImageDigestContentTrust(dockerCli, spec); err != nil { + if err := resolveServiceImageDigestContentTrust(dockerCLI, spec); err != nil { return err } if !options.noResolveImage && versions.GreaterThanOrEqualTo(apiClient.ClientVersion(), "1.30") { @@ -225,7 +225,7 @@ func runUpdate(ctx context.Context, dockerCli command.Cli, flags *pflag.FlagSet, // Retrieve encoded auth token from the image reference // This would be the old image if it didn't change in this update image := spec.TaskTemplate.ContainerSpec.Image - encodedAuth, err := command.RetrieveAuthTokenFromImage(dockerCli.ConfigFile(), image) + encodedAuth, err := command.RetrieveAuthTokenFromImage(dockerCLI.ConfigFile(), image) if err != nil { return err } @@ -242,16 +242,16 @@ func runUpdate(ctx context.Context, dockerCli command.Cli, flags *pflag.FlagSet, } for _, warning := range response.Warnings { - fmt.Fprintln(dockerCli.Err(), warning) + _, _ = fmt.Fprintln(dockerCLI.Err(), warning) } - fmt.Fprintf(dockerCli.Out(), "%s\n", serviceID) + _, _ = fmt.Fprintln(dockerCLI.Out(), serviceID) if options.detach || versions.LessThan(apiClient.ClientVersion(), "1.29") { return nil } - return WaitOnService(ctx, dockerCli, serviceID, options.quiet) + return WaitOnService(ctx, dockerCLI, serviceID, options.quiet) } //nolint:gocyclo