cli/command/service: fix "unused-receiver" linting

cli/command/service/update_test.go:511:7: unused-receiver: method receiver 's' is not referenced in method's body, consider removing or renaming it as _ (revive)
    func (s secretAPIClientMock) SecretCreate(context.Context, swarm.SecretSpec) (types.SecretCreateResponse, error) {
          ^
    cli/command/service/update_test.go:515:7: unused-receiver: method receiver 's' is not referenced in method's body, consider removing or renaming it as _ (revive)
    func (s secretAPIClientMock) SecretRemove(context.Context, string) error {
          ^
    cli/command/service/update_test.go:519:7: unused-receiver: method receiver 's' is not referenced in method's body, consider removing or renaming it as _ (revive)
    func (s secretAPIClientMock) SecretInspectWithRaw(context.Context, string) (swarm.Secret, []byte, error) {
          ^
    cli/command/service/generic_resource_opts.go:46: line-length-limit: line is 206 characters, out of limit 200 (revive)
                return nil, fmt.Errorf("invalid generic-resource request `%s=%s`, Named Generic Resources is not supported for service create or update", res.NamedResourceSpec.Kind, res.NamedResourceSpec.Value)
    cli/command/service/create_test.go:24:7: unused-receiver: method receiver 'f' is not referenced in method's body, consider removing or renaming it as _ (revive)
    func (f fakeConfigAPIClientList) ConfigCreate(_ context.Context, _ swarm.ConfigSpec) (types.ConfigCreateResponse, error) {
          ^
    cli/command/service/logs.go:320:7: unused-receiver: method receiver 'lw' is not referenced in method's body, consider removing or renaming it as _ (revive)
    func (lw *logWriter) parseContext(details map[string]string) (logContext, error) {
          ^
    cli/command/service/opts.go:45:7: unused-receiver: method receiver 'i' is not referenced in method's body, consider removing or renaming it as _ (revive)
    func (i *Uint64Opt) Type() string {
          ^
    cli/command/service/update_test.go:523:7: unused-receiver: method receiver 's' is not referenced in method's body, consider removing or renaming it as _ (revive)
    func (s secretAPIClientMock) SecretUpdate(context.Context, string, swarm.Version, swarm.SecretSpec) error {
          ^
    cli/command/service/create_test.go:28:7: unused-receiver: method receiver 'f' is not referenced in method's body, consider removing or renaming it as _ (revive)
    func (f fakeConfigAPIClientList) ConfigRemove(_ context.Context, _ string) error {
          ^
    cli/command/service/opts.go:70:7: unused-receiver: method receiver 'f' is not referenced in method's body, consider removing or renaming it as _ (revive)
    func (f *floatValue) Type() string {
          ^
    cli/command/service/opts.go:117:7: unused-receiver: method receiver 'o' is not referenced in method's body, consider removing or renaming it as _ (revive)
    func (o *placementPrefOpts) Type() string {
          ^
    cli/command/service/create_test.go:32:7: unused-receiver: method receiver 'f' is not referenced in method's body, consider removing or renaming it as _ (revive)
    func (f fakeConfigAPIClientList) ConfigInspectWithRaw(_ context.Context, _ string) (swarm.Config, []byte, error) {
          ^
    cli/command/service/create_test.go:36:7: unused-receiver: method receiver 'f' is not referenced in method's body, consider removing or renaming it as _ (revive)
    func (f fakeConfigAPIClientList) ConfigUpdate(_ context.Context, _ string, _ swarm.Version, _ swarm.ConfigSpec) error {
          ^
    cli/command/service/opts.go:135:7: unused-receiver: method receiver 's' is not referenced in method's body, consider removing or renaming it as _ (revive)
    func (s *ShlexOpt) Type() string {
          ^
    cli/command/service/opts.go:366:7: unused-receiver: method receiver 'c' is not referenced in method's body, consider removing or renaming it as _ (revive)
    func (c *credentialSpecOpt) Type() string {
          ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2025-02-17 14:27:56 +01:00
parent 5ef673bb14
commit 994e1b7cad
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
5 changed files with 18 additions and 16 deletions

View File

@ -21,19 +21,19 @@ func (f fakeConfigAPIClientList) ConfigList(ctx context.Context, opts types.Conf
return f(ctx, opts) return f(ctx, opts)
} }
func (f fakeConfigAPIClientList) ConfigCreate(_ context.Context, _ swarm.ConfigSpec) (types.ConfigCreateResponse, error) { func (fakeConfigAPIClientList) ConfigCreate(_ context.Context, _ swarm.ConfigSpec) (types.ConfigCreateResponse, error) {
return types.ConfigCreateResponse{}, nil return types.ConfigCreateResponse{}, nil
} }
func (f fakeConfigAPIClientList) ConfigRemove(_ context.Context, _ string) error { func (fakeConfigAPIClientList) ConfigRemove(_ context.Context, _ string) error {
return nil return nil
} }
func (f fakeConfigAPIClientList) ConfigInspectWithRaw(_ context.Context, _ string) (swarm.Config, []byte, error) { func (fakeConfigAPIClientList) ConfigInspectWithRaw(_ context.Context, _ string) (swarm.Config, []byte, error) {
return swarm.Config{}, nil, nil return swarm.Config{}, nil, nil
} }
func (f fakeConfigAPIClientList) ConfigUpdate(_ context.Context, _ string, _ swarm.Version, _ swarm.ConfigSpec) error { func (fakeConfigAPIClientList) ConfigUpdate(_ context.Context, _ string, _ swarm.Version, _ swarm.ConfigSpec) error {
return nil return nil
} }

View File

@ -43,7 +43,9 @@ func ParseGenericResources(value []string) ([]swarm.GenericResource, error) {
swarmResources := genericResourcesFromGRPC(resources) swarmResources := genericResourcesFromGRPC(resources)
for _, res := range swarmResources { for _, res := range swarmResources {
if res.NamedResourceSpec != nil { if res.NamedResourceSpec != nil {
return nil, fmt.Errorf("invalid generic-resource request `%s=%s`, Named Generic Resources is not supported for service create or update", res.NamedResourceSpec.Kind, res.NamedResourceSpec.Value) return nil, fmt.Errorf("invalid generic-resource request `%s=%s`, Named Generic Resources is not supported for service create or update",
res.NamedResourceSpec.Kind, res.NamedResourceSpec.Value,
)
} }
} }

View File

@ -265,7 +265,7 @@ func (lw *logWriter) Write(buf []byte) (int, error) {
// and then create a context from the details // and then create a context from the details
// this removes the context-specific details from the details map, so we // this removes the context-specific details from the details map, so we
// can more easily print the details later // can more easily print the details later
logCtx, err := lw.parseContext(details) logCtx, err := parseContext(details)
if err != nil { if err != nil {
return 0, err return 0, err
} }
@ -317,7 +317,7 @@ func (lw *logWriter) Write(buf []byte) (int, error) {
} }
// parseContext returns a log context and REMOVES the context from the details map // parseContext returns a log context and REMOVES the context from the details map
func (lw *logWriter) parseContext(details map[string]string) (logContext, error) { func parseContext(details map[string]string) (logContext, error) {
nodeID, ok := details["com.docker.swarm.node.id"] nodeID, ok := details["com.docker.swarm.node.id"]
if !ok { if !ok {
return logContext{}, errors.Errorf("missing node id in details: %v", details) return logContext{}, errors.Errorf("missing node id in details: %v", details)

View File

@ -42,7 +42,7 @@ func (i *Uint64Opt) Set(s string) error {
} }
// Type returns the type of this option, which will be displayed in `--help` output // Type returns the type of this option, which will be displayed in `--help` output
func (i *Uint64Opt) Type() string { func (*Uint64Opt) Type() string {
return "uint" return "uint"
} }
@ -67,7 +67,7 @@ func (f *floatValue) Set(s string) error {
return err return err
} }
func (f *floatValue) Type() string { func (*floatValue) Type() string {
return "float" return "float"
} }
@ -114,7 +114,7 @@ func (o *placementPrefOpts) Set(value string) error {
} }
// Type returns a string name for this Option type // Type returns a string name for this Option type
func (o *placementPrefOpts) Type() string { func (*placementPrefOpts) Type() string {
return "pref" return "pref"
} }
@ -132,7 +132,7 @@ func (s *ShlexOpt) Set(value string) error {
} }
// Type returns the type of the value // Type returns the type of the value
func (s *ShlexOpt) Type() string { func (*ShlexOpt) Type() string {
return "command" return "command"
} }
@ -363,7 +363,7 @@ func (c *credentialSpecOpt) Set(value string) error {
return nil return nil
} }
func (c *credentialSpecOpt) Type() string { func (*credentialSpecOpt) Type() string {
return "credential-spec" return "credential-spec"
} }

View File

@ -508,19 +508,19 @@ func (s secretAPIClientMock) SecretList(context.Context, types.SecretListOptions
return s.listResult, nil return s.listResult, nil
} }
func (s secretAPIClientMock) SecretCreate(context.Context, swarm.SecretSpec) (types.SecretCreateResponse, error) { func (secretAPIClientMock) SecretCreate(context.Context, swarm.SecretSpec) (types.SecretCreateResponse, error) {
return types.SecretCreateResponse{}, nil return types.SecretCreateResponse{}, nil
} }
func (s secretAPIClientMock) SecretRemove(context.Context, string) error { func (secretAPIClientMock) SecretRemove(context.Context, string) error {
return nil return nil
} }
func (s secretAPIClientMock) SecretInspectWithRaw(context.Context, string) (swarm.Secret, []byte, error) { func (secretAPIClientMock) SecretInspectWithRaw(context.Context, string) (swarm.Secret, []byte, error) {
return swarm.Secret{}, []byte{}, nil return swarm.Secret{}, []byte{}, nil
} }
func (s secretAPIClientMock) SecretUpdate(context.Context, string, swarm.Version, swarm.SecretSpec) error { func (secretAPIClientMock) SecretUpdate(context.Context, string, swarm.Version, swarm.SecretSpec) error {
return nil return nil
} }