Skip to content

Commit

Permalink
Fix linter issues. (#592)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit91 authored Nov 11, 2024
1 parent 3f09c81 commit fe228e8
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 15 deletions.
8 changes: 4 additions & 4 deletions cmd/metal-api/internal/eventbus/nsq.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (n *NSQClient) CreateEndpoints(lookupds ...string) error {
}

// WaitForTopicsCreated blocks until the topices are created within the given partitions.
func (n NSQClient) WaitForTopicsCreated(partitions metal.Partitions, topics []metal.NSQTopic) {
func (n *NSQClient) WaitForTopicsCreated(partitions metal.Partitions, topics []metal.NSQTopic) {
for {
if err := n.createTopics(partitions, topics); err != nil {
n.logger.Error("cannot create topics", "error", err)
Expand All @@ -71,7 +71,7 @@ func (n NSQClient) WaitForTopicsCreated(partitions metal.Partitions, topics []me
}

// CreateTopic creates a topic with given name.
func (n NSQClient) CreateTopic(name string) error {
func (n *NSQClient) CreateTopic(name string) error {
if err := n.Publisher.CreateTopic(name); err != nil {
n.logger.Error("cannot create topic", "topic", name)
return err
Expand All @@ -80,7 +80,7 @@ func (n NSQClient) CreateTopic(name string) error {
return nil
}

func (n NSQClient) createTopics(partitions metal.Partitions, topics []metal.NSQTopic) error {
func (n *NSQClient) createTopics(partitions metal.Partitions, topics []metal.NSQTopic) error {
for _, topic := range topics {
if topic.PartitionAgnostic {
continue
Expand All @@ -106,6 +106,6 @@ func (n NSQClient) createTopics(partitions metal.Partitions, topics []metal.NSQT
return nil
}

func (n NSQClient) delay() {
func (n *NSQClient) delay() {
time.Sleep(nsqdRetryDelay)
}
2 changes: 1 addition & 1 deletion cmd/metal-api/internal/grpc/grpc-server.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func Run(cfg *ServerConfig) error {
})
grpcPanicRecoveryHandler := func(p any) (err error) {
panicsTotal.Inc()
log.Error("msg", "recovered from panic", "panic", p, "stack", debug.Stack())
log.Error("recovered from panic", "panic", p, "stack", debug.Stack())
return status.Errorf(codes.Internal, "%s", p)
}

Expand Down
6 changes: 5 additions & 1 deletion cmd/metal-api/internal/metal/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,11 @@ type (
)

// Validate a existing FilesystemLayout
func (f FilesystemLayout) Validate() error {
func (f *FilesystemLayout) Validate() error {
if f == nil {
return nil
}

// check device existence from disk.partition -> raid.device -> filesystem
// collect all provided devices
providedDevices := make(map[string]bool)
Expand Down
9 changes: 7 additions & 2 deletions cmd/metal-api/internal/metal/size_reservation.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,16 @@ type SizeReservation struct {

type SizeReservations []SizeReservation

func (rs SizeReservations) BySize() map[string]SizeReservations {
func (rs *SizeReservations) BySize() map[string]SizeReservations {
res := map[string]SizeReservations{}
for _, rv := range rs {
if rs == nil {
return res
}

for _, rv := range *rs {
res[rv.SizeID] = append(res[rv.SizeID], rv)
}

return res
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/metal-api/internal/service/audit-service.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func NewAudit(log *slog.Logger, a auditing.Auditing) *restful.WebService {
return ir.webService()
}

func (r auditResource) webService() *restful.WebService {
func (r *auditResource) webService() *restful.WebService {
ws := new(restful.WebService)
ws.
Path(BasePath + "v1/audit").
Expand Down
2 changes: 1 addition & 1 deletion cmd/metal-api/internal/service/firewall-service.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ func (r *firewallResource) allocateFirewall(request *restful.Request, response *
r.send(request, response, http.StatusOK, resp)
}

func (r firewallResource) setVPNConfigInSpec(ctx context.Context, allocationSpec *machineAllocationSpec) error {
func (r *firewallResource) setVPNConfigInSpec(ctx context.Context, allocationSpec *machineAllocationSpec) error {
if r.headscaleClient == nil {
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/metal-api/internal/service/image-service.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func NewImage(log *slog.Logger, ds *datastore.RethinkStore) *restful.WebService
return ir.webService()
}

func (ir imageResource) webService() *restful.WebService {
func (ir *imageResource) webService() *restful.WebService {
ws := new(restful.WebService)
ws.
Path(BasePath + "v1/image").
Expand Down
3 changes: 1 addition & 2 deletions cmd/metal-api/internal/service/image-service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"log/slog"
"net/http"
"net/http/httptest"
"strings"
"testing"

"github.com/metal-stack/metal-api/cmd/metal-api/internal/datastore"
Expand Down Expand Up @@ -183,7 +182,7 @@ func TestCreateImageWithBrokenURL(t *testing.T) {
var result httperrors.HTTPErrorResponse
err = json.NewDecoder(resp.Body).Decode(&result)
require.NoError(t, err)
require.True(t, strings.Contains(result.Message, "is not accessible under"))
require.Contains(t, result.Message, "is not accessible under")

createRequest.URL = "http://images.metal-stack.io/this-file-does-not-exist"

Expand Down
4 changes: 2 additions & 2 deletions cmd/metal-api/internal/service/machine-service.go
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ func (r *machineResource) setMachineState(request *restful.Request, response *re
r.send(request, response, http.StatusOK, resp)
}

func (r machineResource) findIPMIMachine(request *restful.Request, response *restful.Response) {
func (r *machineResource) findIPMIMachine(request *restful.Request, response *restful.Response) {
id := request.PathParameter("id")

m, err := r.ds.FindMachineByID(id)
Expand Down Expand Up @@ -1782,7 +1782,7 @@ func uniqueTags(tags []string) []string {
return uniqueTags
}

func (r machineResource) freeMachine(request *restful.Request, response *restful.Response) {
func (r *machineResource) freeMachine(request *restful.Request, response *restful.Response) {
id := request.PathParameter("id")
m, err := r.ds.FindMachineByID(id)
if err != nil {
Expand Down

0 comments on commit fe228e8

Please sign in to comment.