mirror of https://github.com/docker/cli.git
golangci-lint: enable nilerr linter
cli/command/idresolver/idresolver.go:33:4: error is not nil (line 31) but it returns nil (nilerr) return id, nil ^ cli/command/idresolver/idresolver.go:45:4: error is not nil (line 43) but it returns nil (nilerr) return id, nil ^ Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
7e9d2c78c6
commit
8bbdb93cf9
|
@ -15,6 +15,7 @@ linters:
|
||||||
- megacheck
|
- megacheck
|
||||||
- misspell
|
- misspell
|
||||||
- nakedret
|
- nakedret
|
||||||
|
- nilerr # Detects code that returns nil even if it checks that the error is not nil.
|
||||||
- predeclared
|
- predeclared
|
||||||
- revive
|
- revive
|
||||||
- staticcheck
|
- staticcheck
|
||||||
|
|
|
@ -30,7 +30,8 @@ func (r *IDResolver) get(ctx context.Context, t interface{}, id string) (string,
|
||||||
case swarm.Node:
|
case swarm.Node:
|
||||||
node, _, err := r.client.NodeInspectWithRaw(ctx, id)
|
node, _, err := r.client.NodeInspectWithRaw(ctx, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return id, nil
|
// TODO(thaJeztah): should error-handling be more specific, or is it ok to ignore any error?
|
||||||
|
return id, nil //nolint:nilerr // ignore nil-error being returned, as this is a best-effort.
|
||||||
}
|
}
|
||||||
if node.Spec.Annotations.Name != "" {
|
if node.Spec.Annotations.Name != "" {
|
||||||
return node.Spec.Annotations.Name, nil
|
return node.Spec.Annotations.Name, nil
|
||||||
|
@ -42,7 +43,8 @@ func (r *IDResolver) get(ctx context.Context, t interface{}, id string) (string,
|
||||||
case swarm.Service:
|
case swarm.Service:
|
||||||
service, _, err := r.client.ServiceInspectWithRaw(ctx, id, types.ServiceInspectOptions{})
|
service, _, err := r.client.ServiceInspectWithRaw(ctx, id, types.ServiceInspectOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return id, nil
|
// TODO(thaJeztah): should error-handling be more specific, or is it ok to ignore any error?
|
||||||
|
return id, nil //nolint:nilerr // ignore nil-error being returned, as this is a best-effort.
|
||||||
}
|
}
|
||||||
return service.Spec.Annotations.Name, nil
|
return service.Spec.Annotations.Name, nil
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in New Issue