Skip to content

Commit 49301cf

Browse files
authored
update hack/tools, update golangci-lint and fix lints (#879)
* update tools Signed-off-by: cpanato <[email protected]> * fix lints Signed-off-by: cpanato <[email protected]> --------- Signed-off-by: cpanato <[email protected]>
1 parent 28e1a87 commit 49301cf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+998
-1525
lines changed

.github/dependabot.yml

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ version: 2
22
updates:
33
- package-ecosystem: "gomod"
44
directory: "/"
5+
directories:
6+
- "/"
7+
- "./hack/tools"
58
schedule:
69
interval: "weekly"
710
labels:

.golangci.yml

+26-17
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,27 @@
11
run:
2-
go: "1.18"
2+
go: "1.22"
33
timeout: 10m
44
tests: false
55
allow-parallel-runners: true
6-
skip-dirs:
7-
- "./*/mock"
86

97
linters-settings:
108
funlen:
119
lines: 110
1210
statements: 60
13-
staticcheck:
14-
go: "1.18"
15-
stylecheck:
16-
go: "1.18"
1711
cyclop:
1812
max-complexity: 15
1913
skip-tests: true
2014
gosec:
2115
exclude-generated: true
16+
excludes:
17+
- G108
2218
lll:
2319
line-length: 120
2420
misspell:
25-
locale: GB
21+
locale: UK
2622
goimports:
2723
local-prefixes: github.com/liquidmetal-dev/flintlock
28-
govet:
29-
check-shadowing: true
3024
nolintlint:
31-
allow-leading-space: false
3225
allow-unused: false
3326
require-explanation: true
3427
require-specific: false
@@ -85,21 +78,37 @@ issues:
8578
- path: test/e2e/
8679
linters:
8780
- goerr113
88-
- gomnd
81+
- mnd
8982
# remove this once https://github.com/golangci/golangci-lint/issues/2649 is closed
9083
- path: /
9184
linters:
9285
- typecheck
86+
exclude-dirs:
87+
- "./*/mock"
9388

9489
linters:
9590
enable-all: true
9691
disable:
97-
- exhaustivestruct
98-
- golint
99-
- interfacer
92+
- bodyclose
93+
- contextcheck
94+
- cyclop
95+
- depguard
96+
- exhaustruct
97+
- err113
98+
- forcetypeassert
10099
- ireturn
101-
- maligned
100+
- interfacebloat
101+
- inamedparam
102+
- musttag
103+
- nonamedreturns
102104
- nilnil
103-
- scopelint
104105
- tagliatelle
105106
- gomoddirectives
107+
- gochecknoglobals
108+
- gci
109+
- varnamelen
110+
- protogetter
111+
- gomnd
112+
- mnd
113+
- wsl
114+
- wrapcheck

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ generate: ## Generate code
8888
$(MAKE) generate-di
8989

9090
.PHONY: generate-go
91-
generate-go: $(MOCKGEN) ## Generate Go Code
91+
generate-go: $(MOCKGEN) ## Generate Go Code
9292
go generate ./infrastructure/mock
9393

9494
.PHONY: generate-proto ## Generate protobuf/grpc code
@@ -165,7 +165,7 @@ $(GOLANGCI_LINT): $(TOOLS_DIR)/go.mod # Get and build golangci-lint
165165
cd $(TOOLS_DIR); go build -tags=tools -o $(subst hack/tools/,,$@) github.com/golangci/golangci-lint/cmd/golangci-lint
166166

167167
$(GINKGO): $(TOOLS_DIR)/go.mod # Get and build gginkgo
168-
cd $(TOOLS_DIR); go build -tags=tools -o $(subst hack/tools/,,$@) github.com/onsi/ginkgo/ginkgo
168+
cd $(TOOLS_DIR); go build -tags=tools -o $(subst hack/tools/,,$@) github.com/onsi/ginkgo/v2/ginkgo
169169

170170
$(MOCKGEN): $(TOOLS_DIR)/go.mod # Get and build mockgen
171171
cd $(TOOLS_DIR); go build -tags=tools -o $(subst hack/tools/,,$@) github.com/golang/mock/mockgen

api/go.mod

+8-7
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,17 @@ go 1.17
44

55
require (
66
github.com/containerd/typeurl/v2 v2.1.0
7-
github.com/grpc-ecosystem/grpc-gateway/v2 v2.6.0
7+
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0
88
google.golang.org/genproto v0.0.0-20211021150943-2b146023228c
9-
google.golang.org/grpc v1.41.0
10-
google.golang.org/protobuf v1.27.1
9+
google.golang.org/grpc v1.64.0
10+
google.golang.org/protobuf v1.34.1
1111
)
1212

1313
require (
1414
github.com/gogo/protobuf v1.3.2 // indirect
15-
github.com/golang/protobuf v1.5.2 // indirect
16-
golang.org/x/net v0.8.0 // indirect
17-
golang.org/x/sys v0.6.0 // indirect
18-
golang.org/x/text v0.8.0 // indirect
15+
github.com/golang/protobuf v1.5.4 // indirect
16+
github.com/google/go-cmp v0.6.0 // indirect
17+
golang.org/x/net v0.23.0 // indirect
18+
golang.org/x/sys v0.18.0 // indirect
19+
golang.org/x/text v0.15.0 // indirect
1920
)

api/go.sum

+16-308
Large diffs are not rendered by default.

cmd/flintlock-metrics/main.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ package main
33
import (
44
"os"
55

6-
"github.com/liquidmetal-dev/flintlock/internal/command/metrics"
76
"github.com/sirupsen/logrus"
7+
8+
"github.com/liquidmetal-dev/flintlock/internal/command/metrics"
89
)
910

1011
func main() {

core/application/commands.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import (
55
"encoding/base64"
66
"fmt"
77

8+
"github.com/sirupsen/logrus"
9+
"sigs.k8s.io/yaml"
10+
811
"github.com/liquidmetal-dev/flintlock/api/events"
912
"github.com/liquidmetal-dev/flintlock/client/cloudinit"
1013
"github.com/liquidmetal-dev/flintlock/client/cloudinit/instance"
@@ -14,8 +17,6 @@ import (
1417
"github.com/liquidmetal-dev/flintlock/pkg/defaults"
1518
"github.com/liquidmetal-dev/flintlock/pkg/log"
1619
"github.com/liquidmetal-dev/flintlock/pkg/validation"
17-
"github.com/sirupsen/logrus"
18-
"sigs.k8s.io/yaml"
1920
)
2021

2122
const (
@@ -216,6 +217,4 @@ func (a *app) addMetadataInterface(mvm *models.MicroVM) {
216217
}
217218
interfaces = append(interfaces, mvm.Spec.NetworkInterfaces...)
218219
mvm.Spec.NetworkInterfaces = interfaces
219-
220-
return
221220
}

core/application/reconcile.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import (
55
"fmt"
66
"time"
77

8+
"github.com/sirupsen/logrus"
9+
810
"github.com/liquidmetal-dev/flintlock/api/events"
911
"github.com/liquidmetal-dev/flintlock/core/models"
1012
"github.com/liquidmetal-dev/flintlock/core/plans"
@@ -13,7 +15,6 @@ import (
1315
"github.com/liquidmetal-dev/flintlock/pkg/defaults"
1416
"github.com/liquidmetal-dev/flintlock/pkg/log"
1517
"github.com/liquidmetal-dev/flintlock/pkg/planner"
16-
"github.com/sirupsen/logrus"
1718
)
1819

1920
const backoffBaseInSeconds = 20

core/errors/errors.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ var (
1717
ErrNoMount = errors.New("no image mount point")
1818
ErrNoVolumeMount = errors.New("no volume mount point")
1919
ErrParentIfaceRequiredForMacvtap = errors.New("a parent network device name is required for macvtap interfaces")
20-
ErrParentIfaceRequiredForAttachingTap = errors.New("a parent network device name is required for attaching a TAP interface")
20+
ErrParentIfaceRequiredForAttachingTap = errors.New("a parent network device name is required for attaching a TAP interface") //nolint: lll // that is okay
2121
ErrGuestDeviceNameRequired = errors.New("a guest device name is required")
2222
ErrUnsupportedIfaceType = errors.New("unsupported network interface type")
2323
ErrIfaceNotFound = errors.New("network interface not found")
@@ -41,7 +41,7 @@ type IncorrectVMIDFormatError struct {
4141

4242
// Error returns the error message.
4343
func (e IncorrectVMIDFormatError) Error() string {
44-
return fmt.Sprintf("unexpected vmid format: %s", e.ActualID)
44+
return "unexpected vmid format: " + e.ActualID
4545
}
4646

4747
func NewErrUnsupportedInterface(ifaceType string) UnsupportedInterfaceError {
@@ -136,7 +136,7 @@ type notSupportedError struct {
136136

137137
// Error returns the error message.
138138
func (e notSupportedError) Error() string {
139-
return fmt.Sprintf("%s is not supported", e.unsupported)
139+
return e.unsupported + "is not supported"
140140
}
141141

142142
// IsNotSupported tests an error to see if its a not supported error.

core/models/volumes.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func (v Volumes) GetByID(id string) *Volume {
3232
}
3333

3434
// HasMountableVolumes returns true if any of the volumes
35-
// have a mount point defined
35+
// have a mount point defined.
3636
func (v Volumes) HasMountableVolumes() bool {
3737
for _, vol := range v {
3838
if vol.MountPoint != "" {

core/plans/types.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package plans
22

33
import (
4-
"github.com/liquidmetal-dev/flintlock/core/ports"
54
"github.com/spf13/afero"
5+
6+
"github.com/liquidmetal-dev/flintlock/core/ports"
67
)
78

89
// Providers input is a type to be used as input to plans.

core/steps/cloudinit/disk_mount.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func (s *diskMountStep) Do(ctx context.Context) ([]planner.Procedure, error) {
119119
return nil, nil
120120
}
121121

122-
func (s *diskMountStep) Verify(ctx context.Context) error {
122+
func (s *diskMountStep) Verify(_ context.Context) error {
123123
return nil
124124
}
125125

core/steps/event/publish.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ import (
44
"context"
55
"fmt"
66

7+
"github.com/sirupsen/logrus"
8+
79
"github.com/liquidmetal-dev/flintlock/core/ports"
810
"github.com/liquidmetal-dev/flintlock/pkg/log"
911
"github.com/liquidmetal-dev/flintlock/pkg/planner"
10-
"github.com/sirupsen/logrus"
1112
)
1213

1314
func NewPublish(topic string, event interface{}, eventSvc ports.EventService) planner.Procedure {
@@ -29,7 +30,7 @@ func (s *eventPublish) Name() string {
2930
return "event_publish"
3031
}
3132

32-
func (s *eventPublish) ShouldDo(ctx context.Context) (bool, error) {
33+
func (s *eventPublish) ShouldDo(_ context.Context) (bool, error) {
3334
return true, nil
3435
}
3536

@@ -47,6 +48,6 @@ func (s *eventPublish) Do(ctx context.Context) ([]planner.Procedure, error) {
4748
return nil, nil
4849
}
4950

50-
func (s *eventPublish) Verify(ctx context.Context) error {
51+
func (s *eventPublish) Verify(_ context.Context) error {
5152
return nil
5253
}

core/steps/event/publish_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ import (
66
"testing"
77

88
"github.com/golang/mock/gomock"
9+
g "github.com/onsi/gomega"
10+
911
"github.com/liquidmetal-dev/flintlock/api/events"
1012
"github.com/liquidmetal-dev/flintlock/core/steps/event"
1113
"github.com/liquidmetal-dev/flintlock/infrastructure/mock"
12-
g "github.com/onsi/gomega"
1314
)
1415

1516
const (

core/steps/microvm/create.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ import (
44
"context"
55
"fmt"
66

7+
"github.com/sirupsen/logrus"
8+
79
"github.com/liquidmetal-dev/flintlock/core/errors"
810
"github.com/liquidmetal-dev/flintlock/core/models"
911
"github.com/liquidmetal-dev/flintlock/core/ports"
1012
"github.com/liquidmetal-dev/flintlock/pkg/log"
1113
"github.com/liquidmetal-dev/flintlock/pkg/planner"
12-
"github.com/sirupsen/logrus"
1314
)
1415

1516
func NewCreateStep(vm *models.MicroVM, vmSvc ports.MicroVMService) planner.Procedure {
@@ -63,6 +64,6 @@ func (s *createStep) Do(ctx context.Context) ([]planner.Procedure, error) {
6364
return nil, nil
6465
}
6566

66-
func (s *createStep) Verify(ctx context.Context) error {
67+
func (s *createStep) Verify(_ context.Context) error {
6768
return nil
6869
}

core/steps/microvm/create_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ import (
66
"testing"
77

88
"github.com/golang/mock/gomock"
9+
g "github.com/onsi/gomega"
10+
911
internalerr "github.com/liquidmetal-dev/flintlock/core/errors"
1012
"github.com/liquidmetal-dev/flintlock/core/models"
1113
"github.com/liquidmetal-dev/flintlock/core/ports"
1214
"github.com/liquidmetal-dev/flintlock/core/steps/microvm"
1315
"github.com/liquidmetal-dev/flintlock/infrastructure/mock"
14-
g "github.com/onsi/gomega"
1516
)
1617

1718
func testVMToCreate() *models.MicroVM {

core/steps/microvm/delete.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ import (
44
"context"
55
"fmt"
66

7+
"github.com/sirupsen/logrus"
8+
79
"github.com/liquidmetal-dev/flintlock/core/errors"
810
"github.com/liquidmetal-dev/flintlock/core/models"
911
"github.com/liquidmetal-dev/flintlock/core/ports"
1012
"github.com/liquidmetal-dev/flintlock/pkg/log"
1113
"github.com/liquidmetal-dev/flintlock/pkg/planner"
12-
"github.com/sirupsen/logrus"
1314
)
1415

1516
func NewDeleteStep(vm *models.MicroVM, vmSvc ports.MicroVMService) planner.Procedure {
@@ -60,6 +61,6 @@ func (s *deleteStep) Do(ctx context.Context) ([]planner.Procedure, error) {
6061
return nil, nil
6162
}
6263

63-
func (s *deleteStep) Verify(ctx context.Context) error {
64+
func (s *deleteStep) Verify(_ context.Context) error {
6465
return nil
6566
}

core/steps/microvm/delete_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ import (
66
"testing"
77

88
"github.com/golang/mock/gomock"
9+
g "github.com/onsi/gomega"
10+
911
internalerr "github.com/liquidmetal-dev/flintlock/core/errors"
1012
"github.com/liquidmetal-dev/flintlock/core/models"
1113
"github.com/liquidmetal-dev/flintlock/core/ports"
1214
"github.com/liquidmetal-dev/flintlock/core/steps/microvm"
1315
"github.com/liquidmetal-dev/flintlock/infrastructure/mock"
14-
g "github.com/onsi/gomega"
1516
)
1617

1718
func testVMToDelete() *models.MicroVM {

core/steps/microvm/start.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ import (
55
"fmt"
66
"time"
77

8+
"github.com/sirupsen/logrus"
9+
810
"github.com/liquidmetal-dev/flintlock/core/errors"
911
"github.com/liquidmetal-dev/flintlock/core/models"
1012
"github.com/liquidmetal-dev/flintlock/core/ports"
1113
"github.com/liquidmetal-dev/flintlock/pkg/log"
1214
"github.com/liquidmetal-dev/flintlock/pkg/planner"
13-
"github.com/sirupsen/logrus"
1415
)
1516

1617
func NewStartStep(

core/steps/microvm/start_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ import (
66
"testing"
77

88
"github.com/golang/mock/gomock"
9+
g "github.com/onsi/gomega"
10+
911
internalerr "github.com/liquidmetal-dev/flintlock/core/errors"
1012
"github.com/liquidmetal-dev/flintlock/core/models"
1113
"github.com/liquidmetal-dev/flintlock/core/ports"
1214
"github.com/liquidmetal-dev/flintlock/core/steps/microvm"
1315
"github.com/liquidmetal-dev/flintlock/infrastructure/mock"
14-
g "github.com/onsi/gomega"
1516
)
1617

1718
const bootTimeInSeconds = 1

0 commit comments

Comments
 (0)