From 76d2d3be113ed5975a90ccfcfb46ce7beed3cbe2 Mon Sep 17 00:00:00 2001 From: Andreas Fritzler Date: Mon, 28 Oct 2024 14:33:12 +0100 Subject: [PATCH] Fix linting issues by excluding tests and fake server --- .golangci.yml | 9 +++++++++ Makefile | 2 +- broker/machinebroker/cmd/machinebroker/app/app.go | 4 ++-- go.mod | 2 +- go.sum | 4 ++-- hack/tools.go | 2 -- poollet/bucketpoollet/bcm/generic.go | 3 ++- poollet/volumepoollet/vcm/generic.go | 3 ++- 8 files changed, 19 insertions(+), 10 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 59c483f3a..639ee8fcb 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -48,6 +48,15 @@ linters-settings: alias: ${1}client issues: + # exclude copylocks issues in fake servers and unit tests + exclude-files: + - iri/testing/volume/fake.go + - iri/testing/bucket/fake.go + - iri/testing/machine/fake.go + - poollet/machinepoollet/controllers/machine_controller_test.go + # TODO: fis copylocks issues in those files + - poollet/volumepoollet/vcm/generic.go + - poollet/bucketpoollet/bcm/generic.go # don't skip warning about doc comments # don't exclude the default set of lint exclude-use-default: false diff --git a/Makefile b/Makefile index 97584ff63..2b8b3973f 100644 --- a/Makefile +++ b/Makefile @@ -99,7 +99,7 @@ fmt: goimports ## Run goimports against code. .PHONY: vet vet: ## Run go vet against code. - go vet ./... + go vet -copylocks=false ./... .PHONY: lint lint: golangci-lint ## Run golangci-lint on the code. diff --git a/broker/machinebroker/cmd/machinebroker/app/app.go b/broker/machinebroker/cmd/machinebroker/app/app.go index f288a67d3..88598b0d0 100644 --- a/broker/machinebroker/cmd/machinebroker/app/app.go +++ b/broker/machinebroker/cmd/machinebroker/app/app.go @@ -122,7 +122,7 @@ func Run(ctx context.Context, opts Options) error { g, ctx := errgroup.WithContext(ctx) g.Go(func() error { - return runServer(ctx, setupLog, log, srv) + return runServer(ctx, setupLog, srv) }) g.Go(func() error { return runGRPCServer(ctx, setupLog, log, srv, opts) @@ -133,7 +133,7 @@ func Run(ctx context.Context, opts Options) error { return g.Wait() } -func runServer(ctx context.Context, setupLog, _ logr.Logger, srv *server.Server) error { +func runServer(ctx context.Context, setupLog logr.Logger, srv *server.Server) error { setupLog.V(1).Info("Starting server loops") if err := srv.Start(ctx); err != nil { return fmt.Errorf("error starting server loops: %w", err) diff --git a/go.mod b/go.mod index c866310e7..412918f3e 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/ironcore-dev/ironcore go 1.23.2 require ( - github.com/afritzler/protoequal v0.1.0 + github.com/afritzler/protoequal v0.1.1 github.com/bits-and-blooms/bitset v1.14.3 github.com/blang/semver/v4 v4.0.0 github.com/go-chi/chi/v5 v5.1.0 diff --git a/go.sum b/go.sum index fed7aeb57..63fd53e77 100644 --- a/go.sum +++ b/go.sum @@ -6,8 +6,8 @@ github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOEl github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/NYTimes/gziphandler v1.1.1 h1:ZUDjpQae29j0ryrS0u/B8HZfJBtBQHjqw2rQ2cqUQ3I= github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMomdKFjzJNB0c= -github.com/afritzler/protoequal v0.1.0 h1:2D3rLHXQB+wzPOJHuG3H7p/H16g3pEQwyvtkNkS1pYs= -github.com/afritzler/protoequal v0.1.0/go.mod h1:Ube4ogd+UZ3f8PfmeQfO2SJBCLHT6gmkEtpqvXmJhBU= +github.com/afritzler/protoequal v0.1.1 h1:t3jAXLzRrVbkUg3Hom7rQdUck2kpAgR5JD9/68Lht90= +github.com/afritzler/protoequal v0.1.1/go.mod h1:Ube4ogd+UZ3f8PfmeQfO2SJBCLHT6gmkEtpqvXmJhBU= github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230305170008-8188dc5388df h1:7RFfzj4SSt6nnvCPbCqijJi1nWCd+TqAT3bYCStRC18= github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230305170008-8188dc5388df/go.mod h1:pSwJ0fSY5KhvocuWSx4fz3BA8OrA1bQn+K1Eli3BRwM= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= diff --git a/hack/tools.go b/hack/tools.go index f1690ea49..f74bc7e6d 100644 --- a/hack/tools.go +++ b/hack/tools.go @@ -9,7 +9,5 @@ package hack import ( - // Use gogoproto for protobuf generation. - _ "github.com/gogo/protobuf/gogoproto" _ "k8s.io/code-generator" ) diff --git a/poollet/bucketpoollet/bcm/generic.go b/poollet/bucketpoollet/bcm/generic.go index 2c98ff884..8c8eab5d1 100644 --- a/poollet/bucketpoollet/bcm/generic.go +++ b/poollet/bucketpoollet/bcm/generic.go @@ -94,7 +94,8 @@ func (g *Generic) GetBucketClassFor(ctx context.Context, name string, caps *iri. case 0: return nil, ErrNoMatchingBucketClass case 1: - return byCaps[0], nil + class := *byCaps[0] + return &class, nil default: return nil, ErrAmbiguousMatchingBucketClass } diff --git a/poollet/volumepoollet/vcm/generic.go b/poollet/volumepoollet/vcm/generic.go index 45e35694a..8426bb25d 100644 --- a/poollet/volumepoollet/vcm/generic.go +++ b/poollet/volumepoollet/vcm/generic.go @@ -149,7 +149,8 @@ func (g *Generic) GetVolumeClassFor(ctx context.Context, name string, caps *iri. case 0: return nil, nil, ErrNoMatchingVolumeClass case 1: - return byCaps[0].VolumeClass, resource.NewQuantity(byCaps[0].Quantity, resource.BinarySI), nil + classStatus := *byCaps[0] + return classStatus.VolumeClass, resource.NewQuantity(classStatus.Quantity, resource.BinarySI), nil default: return nil, nil, ErrAmbiguousMatchingVolumeClass }