Skip to content

Commit c09fca5

Browse files
committed
[golangci-lint] error-format: fmt.Errorf can be replaced with errors.New
1 parent f17e707 commit c09fca5

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

internal/controller/onboarding_controller.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ import (
4848
"github.com/cobaltcore-dev/openstack-hypervisor-operator/internal/openstack"
4949
)
5050

51-
var errRequeue = fmt.Errorf("requeue requested")
51+
var errRequeue = errors.New("requeue requested")
5252

5353
const (
5454
defaultWaitTime = 1 * time.Minute
@@ -465,7 +465,7 @@ func (r *OnboardingController) createOrGetTestServer(ctx context.Context, zone,
465465
}
466466

467467
if flavorRef == "" {
468-
return nil, fmt.Errorf("couldn't find flavor")
468+
return nil, errors.New("couldn't find flavor")
469469
}
470470

471471
var imageRef string
@@ -488,7 +488,7 @@ func (r *OnboardingController) createOrGetTestServer(ctx context.Context, zone,
488488
}
489489

490490
if imageRef == "" {
491-
return nil, fmt.Errorf("couldn't find image")
491+
return nil, errors.New("couldn't find image")
492492
}
493493

494494
falseVal := false
@@ -509,7 +509,7 @@ func (r *OnboardingController) createOrGetTestServer(ctx context.Context, zone,
509509
}
510510

511511
if networkRef == "" {
512-
return nil, fmt.Errorf("couldn't find network")
512+
return nil, errors.New("couldn't find network")
513513
}
514514

515515
log.Info("creating server", "name", serverName)
@@ -537,7 +537,7 @@ func (r *OnboardingController) createOrGetTestServer(ctx context.Context, zone,
537537
}
538538

539539
if server == nil {
540-
return nil, fmt.Errorf("server is nil")
540+
return nil, errors.New("server is nil")
541541
}
542542
// Apparently the response doesn't contain the value
543543
server.Name = serverName

internal/openstack/hypervisor.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ package openstack
1919

2020
import (
2121
"context"
22-
"fmt"
22+
"errors"
2323
"net/http"
2424

2525
"github.com/gophercloud/gophercloud/v2"
@@ -30,8 +30,8 @@ type HyperVisorsDetails struct {
3030
Hypervisors []hypervisors.Hypervisor `json:"hypervisors"`
3131
}
3232

33-
var ErrNoHypervisor = fmt.Errorf("no hypervisor found")
34-
var ErrMultipleHypervisors = fmt.Errorf("multiple hypervisors found")
33+
var ErrNoHypervisor = errors.New("no hypervisor found")
34+
var ErrMultipleHypervisors = errors.New("multiple hypervisors found")
3535

3636
func GetHypervisorByName(ctx context.Context, sc *gophercloud.ServiceClient, hypervisorHostnamePattern string, withServers bool) (*hypervisors.Hypervisor, error) {
3737
listOpts := hypervisors.ListOpts{

internal/openstack/placement.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package openstack
1919

2020
import (
2121
"context"
22+
"errors"
2223
"fmt"
2324

2425
"github.com/gophercloud/gophercloud/v2"
@@ -146,7 +147,7 @@ func CleanupResourceProvider(ctx context.Context, client *gophercloud.ServiceCli
146147
}
147148

148149
if len(consumerAllocations.Allocations) > 0 {
149-
return fmt.Errorf("cannot clean up provider, cannot handle non-empty consumer allocations")
150+
return errors.New("cannot clean up provider, cannot handle non-empty consumer allocations")
150151
}
151152

152153
// The consumer actually doesn't have *any* allocations, so it is just

0 commit comments

Comments
 (0)