Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add lint pipeline using golangci lint #565

Merged
merged 5 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions .github/workflows/goimports.yml

This file was deleted.

24 changes: 24 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Lint

on:
push:
branches: [main]
pull_request:

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: false

- uses: golangci/golangci-lint-action@v3
with:
version: v1.55.2 # renovate: datasource=github-releases depName=golangci/golangci-lint

# In general linting is quite fast with warm caches, but a fresh run might
# take some time.
args: --timeout 5m
43 changes: 43 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
linters-settings:
errcheck:
exclude-functions:
- (github.com/go-kit/log.Logger).Log
misspell:
locale: US
gci:
sections:
- standard
- default
- prefix(github.com/hetznercloud)

linters:
disable-all: true
enable:
- bodyclose
- errcheck
- exportloopref
- gci
- gocritic
- gofmt
- goimports
- gosimple
- govet
- ineffassign
- misspell
- prealloc
- revive
- rowserrcheck
- staticcheck
- typecheck
- unparam
- unused
- whitespace

issues:
exclude-rules:
- path: _test\.go
linters:
- errcheck
- path: _test\.go
text: unused-parameter
2 changes: 1 addition & 1 deletion api/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (

"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/hetznercloud/hcloud-go/v2/hcloud"

"github.com/hetznercloud/csi-driver/csi"
"github.com/hetznercloud/csi-driver/volumes"
"github.com/hetznercloud/hcloud-go/v2/hcloud"
)

type VolumeService struct {
Expand Down
5 changes: 3 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ import (
"github.com/go-kit/log"
"github.com/go-kit/log/level"
grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
"github.com/prometheus/client_golang/prometheus"
"google.golang.org/grpc"

"github.com/hetznercloud/csi-driver/driver"
"github.com/hetznercloud/csi-driver/metrics"
"github.com/hetznercloud/hcloud-go/v2/hcloud"
"github.com/hetznercloud/hcloud-go/v2/hcloud/metadata"
"github.com/prometheus/client_golang/prometheus"
"google.golang.org/grpc"
)

func parseLogLevel(lvl string) level.Option {
Expand Down
1 change: 1 addition & 0 deletions cmd/aio/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
proto "github.com/container-storage-interface/spec/lib/go/csi"
"github.com/go-kit/log"
"github.com/go-kit/log/level"

"github.com/hetznercloud/csi-driver/api"
"github.com/hetznercloud/csi-driver/app"
"github.com/hetznercloud/csi-driver/driver"
Expand Down
1 change: 1 addition & 0 deletions cmd/controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
proto "github.com/container-storage-interface/spec/lib/go/csi"
"github.com/go-kit/log"
"github.com/go-kit/log/level"

"github.com/hetznercloud/csi-driver/api"
"github.com/hetznercloud/csi-driver/app"
"github.com/hetznercloud/csi-driver/driver"
Expand Down
1 change: 1 addition & 0 deletions cmd/node/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
proto "github.com/container-storage-interface/spec/lib/go/csi"
"github.com/go-kit/log"
"github.com/go-kit/log/level"

"github.com/hetznercloud/csi-driver/app"
"github.com/hetznercloud/csi-driver/driver"
"github.com/hetznercloud/csi-driver/volumes"
Expand Down
8 changes: 4 additions & 4 deletions driver/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (s *ControllerService) CreateVolume(ctx context.Context, req *proto.CreateV
"err", err,
)
code := codes.Internal
switch err {
switch err { //nolint:gocritic
case volumes.ErrVolumeAlreadyExists:
code = codes.AlreadyExists
}
Expand Down Expand Up @@ -368,7 +368,7 @@ func (s *ControllerService) ControllerExpandVolume(ctx context.Context, req *pro

if err := s.volumeService.Resize(ctx, volume, minSize); err != nil {
code := codes.Internal
switch err {
switch err { //nolint:gocritic
case volumes.ErrVolumeNotFound:
code = codes.NotFound
}
Expand All @@ -377,7 +377,7 @@ func (s *ControllerService) ControllerExpandVolume(ctx context.Context, req *pro

if volume, err = s.volumeService.GetByID(ctx, volumeID); err != nil {
code := codes.Internal
switch err {
switch err { //nolint:gocritic
case volumes.ErrVolumeNotFound:
code = codes.NotFound
}
Expand All @@ -391,6 +391,6 @@ func (s *ControllerService) ControllerExpandVolume(ctx context.Context, req *pro
return resp, nil
}

func (s *ControllerService) ControllerGetVolume(ctx context.Context, req *proto.ControllerGetVolumeRequest) (*proto.ControllerGetVolumeResponse, error) {
func (s *ControllerService) ControllerGetVolume(_ context.Context, _ *proto.ControllerGetVolumeRequest) (*proto.ControllerGetVolumeResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ControllerGetVolume not implemented")
}
Loading