Skip to content

Commit a7ca73b

Browse files
committed
mount the local directory to lint container to get changes on host
1 parent b6b9cf9 commit a7ca73b

17 files changed

+61
-58
lines changed

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ endif
3131
#####################################################################
3232
.PHONY: fmt
3333
fmt:
34-
docker run --rm --platform=$(PLATFORM) -it $(IMAGE_TAG) go fmt ./...
34+
docker run --rm -w /workdir -v $(PWD):/workdir --platform=$(PLATFORM) -it $(IMAGE_TAG) go fmt ./...
3535

3636
.PHONY: vet
3737
vet: fmt
38-
docker run --rm --platform=$(PLATFORM) -it $(IMAGE_TAG) go vet ./...
38+
docker run --rm -w /workdir -v $(PWD):/workdir --platform=$(PLATFORM) -it $(IMAGE_TAG) go vet ./...
3939

4040
.PHONY: lint
4141
lint: vet
42-
docker run --rm --platform=$(PLATFORM) -it $(IMAGE_TAG) golangci-lint run -v -c .golangci.yml --fix
42+
docker run --rm -w /workdir -v $(PWD):/workdir --platform=$(PLATFORM) -it $(IMAGE_TAG) golangci-lint run -v -c .golangci.yml --fix
4343

4444
.PHONY: verify
4545
verify:

internal/driver/controllerserver.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,12 @@ func (cs *ControllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
9898
log.V(4).Info("CreateVolume details", "storage_size_giga_bytes", targetSizeGB, "volume_name", volumeName)
9999

100100
volumeContext := make(map[string]string)
101-
if req.Parameters[LuksEncryptedAttribute] == "true" {
101+
if req.GetParameters()[LuksEncryptedAttribute] == "true" {
102102
// if luks encryption is enabled add a volume context
103103
volumeContext[LuksEncryptedAttribute] = "true"
104104
volumeContext[PublishInfoVolumeName] = volumeName
105-
volumeContext[LuksCipherAttribute] = req.Parameters[LuksCipherAttribute]
106-
volumeContext[LuksKeySizeAttribute] = req.Parameters[LuksKeySizeAttribute]
105+
volumeContext[LuksCipherAttribute] = req.GetParameters()[LuksCipherAttribute]
106+
volumeContext[LuksKeySizeAttribute] = req.GetParameters()[LuksKeySizeAttribute]
107107
}
108108

109109
// Attempt to get info about the source volume for
@@ -122,7 +122,7 @@ func (cs *ControllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
122122
ctx,
123123
volumeName,
124124
targetSizeGB,
125-
req.Parameters[VolumeTags],
125+
req.GetParameters()[VolumeTags],
126126
sourceVolumeInfo,
127127
)
128128
if err != nil {

internal/driver/controllerserver_helper.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ import (
99
"time"
1010

1111
"github.com/container-storage-interface/spec/lib/go/csi"
12+
"github.com/linode/linodego"
13+
1214
linodevolumes "github.com/linode/linode-blockstorage-csi-driver/pkg/linode-volumes"
1315
"github.com/linode/linode-blockstorage-csi-driver/pkg/logger"
14-
"github.com/linode/linodego"
1516
)
1617

1718
// MinVolumeSizeBytes is the smallest allowed size for a Linode block storage

internal/driver/controllerserver_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ import (
77
"testing"
88

99
"github.com/container-storage-interface/spec/lib/go/csi"
10+
"github.com/linode/linodego"
11+
1012
linodeclient "github.com/linode/linode-blockstorage-csi-driver/pkg/linode-client"
1113
linodevolumes "github.com/linode/linode-blockstorage-csi-driver/pkg/linode-volumes"
12-
"github.com/linode/linodego"
1314
)
1415

1516
//nolint:gocognit // As simple as possible.
@@ -103,7 +104,7 @@ func TestListVolumes(t *testing.T) {
103104
var linodeVolume *linodego.Volume
104105
for _, v := range tt.volumes {
105106
key := linodevolumes.CreateLinodeVolumeKey(v.ID, v.Label)
106-
if volume.VolumeId == key.GetVolumeKey() {
107+
if volume.GetVolumeId() == key.GetVolumeKey() {
107108
v := v
108109
linodeVolume = &v
109110
break
@@ -113,11 +114,11 @@ func TestListVolumes(t *testing.T) {
113114
t.Fatalf("no matching linode volume for %#v", volume)
114115
}
115116

116-
if want, got := int64(linodeVolume.Size<<30), volume.CapacityBytes; want != got {
117+
if want, got := int64(linodeVolume.Size<<30), volume.GetCapacityBytes(); want != got {
117118
t.Errorf("mismatched volume size: want=%d got=%d", want, got)
118119
}
119120
for _, topology := range volume.GetAccessibleTopology() {
120-
region, ok := topology.Segments[VolumeTopologyRegion]
121+
region, ok := topology.GetSegments()[VolumeTopologyRegion]
121122
if !ok {
122123
t.Error("region not set in volume topology")
123124
}
@@ -131,7 +132,7 @@ func TestListVolumes(t *testing.T) {
131132
t.Error("nil status")
132133
continue
133134
}
134-
if status.VolumeCondition.Abnormal {
135+
if status.GetVolumeCondition().GetAbnormal() {
135136
t.Error("abnormal volume condition")
136137
}
137138

internal/driver/driver.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@ import (
2323
"sync"
2424

2525
"github.com/container-storage-interface/spec/lib/go/csi"
26-
linodeclient "github.com/linode/linode-blockstorage-csi-driver/pkg/linode-client"
2726

28-
"github.com/linode/linode-blockstorage-csi-driver/pkg/logger"
29-
mountmanager "github.com/linode/linode-blockstorage-csi-driver/pkg/mount-manager"
3027
"google.golang.org/grpc/codes"
3128
"google.golang.org/grpc/status"
3229
"k8s.io/mount-utils"
30+
31+
linodeclient "github.com/linode/linode-blockstorage-csi-driver/pkg/linode-client"
32+
"github.com/linode/linode-blockstorage-csi-driver/pkg/logger"
33+
mountmanager "github.com/linode/linode-blockstorage-csi-driver/pkg/mount-manager"
3334
)
3435

3536
// Name is the name of the driver provided by this package.
@@ -141,7 +142,7 @@ func (linodeDriver *LinodeDriver) ValidateControllerServiceRequest(ctx context.C
141142
}
142143

143144
for _, cap := range linodeDriver.cscap {
144-
if rpcType == cap.GetRpc().Type {
145+
if rpcType == cap.GetRpc().GetType() {
145146
log.V(4).Info("Controller service request validated successfully")
146147
return nil
147148
}

internal/driver/driver_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ import (
66
"os"
77
"testing"
88

9-
"github.com/linode/linode-blockstorage-csi-driver/mocks"
10-
linodeclient "github.com/linode/linode-blockstorage-csi-driver/pkg/linode-client"
119
"k8s.io/mount-utils"
1210

1311
"go.uber.org/mock/gomock"
12+
13+
"github.com/linode/linode-blockstorage-csi-driver/mocks"
14+
linodeclient "github.com/linode/linode-blockstorage-csi-driver/pkg/linode-client"
1415
)
1516

1617
var (

internal/driver/identityserver.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ import (
1818
"fmt"
1919

2020
csi "github.com/container-storage-interface/spec/lib/go/csi"
21-
"github.com/linode/linode-blockstorage-csi-driver/pkg/logger"
2221
"golang.org/x/net/context"
2322
"google.golang.org/grpc/codes"
2423
"google.golang.org/grpc/status"
2524
"google.golang.org/protobuf/types/known/wrapperspb"
25+
26+
"github.com/linode/linode-blockstorage-csi-driver/pkg/logger"
2627
)
2728

2829
// IdentityServer implements the CSI Identity service for the Linode Block Storage CSI Driver.

internal/driver/luks.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,8 @@ import (
2929
"strconv"
3030
"strings"
3131

32-
utilexec "k8s.io/utils/exec"
33-
3432
cryptsetup "github.com/martinjungblut/go-cryptsetup"
33+
utilexec "k8s.io/utils/exec"
3534

3635
cryptsetupclient "github.com/linode/linode-blockstorage-csi-driver/pkg/cryptsetup-client"
3736
"github.com/linode/linode-blockstorage-csi-driver/pkg/logger"
@@ -209,13 +208,13 @@ func (e *Encryption) luksOpen(ctx context.Context, luksCtx *LuksContext, source
209208
func (e *Encryption) luksClose(ctx context.Context, volumeName string) error {
210209
log := logger.GetLogger(ctx)
211210
// Initialize the device by name
212-
log.V(4).Info("Initalizing device to perform luks close", "volumeName", volumeName)
211+
log.V(4).Info("Initializing device to perform luks close", "volumeName", volumeName)
213212
newLuksDeviceByName, err := cryptsetupclient.NewLuksDeviceByName(e.CryptSetup, volumeName)
214213
if err != nil {
215214
log.V(4).Info("device is no longer active", "volumeName", volumeName)
216215
return nil
217216
}
218-
log.V(4).Info("Initalized device to perform luks close", "volumeName", volumeName)
217+
log.V(4).Info("Initialized device to perform luks close", "volumeName", volumeName)
219218

220219
// Deactivating the device
221220
log.V(4).Info("Deactivating and closing the volume", "volumeName", volumeName)

internal/driver/metadata.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ import (
99
"strconv"
1010

1111
metadata "github.com/linode/go-metadata"
12-
"github.com/linode/linode-blockstorage-csi-driver/pkg/logger"
1312
"github.com/linode/linodego"
13+
14+
"github.com/linode/linode-blockstorage-csi-driver/pkg/logger"
1415
)
1516

1617
// Metadata contains metadata about the node/instance the CSI node plugin

internal/driver/nodeserver.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@ import (
2121
"sync"
2222

2323
"github.com/container-storage-interface/spec/lib/go/csi"
24+
"github.com/linode/linodego"
25+
"golang.org/x/net/context"
26+
"k8s.io/mount-utils"
27+
2428
linodeclient "github.com/linode/linode-blockstorage-csi-driver/pkg/linode-client"
2529
linodevolumes "github.com/linode/linode-blockstorage-csi-driver/pkg/linode-volumes"
2630
"github.com/linode/linode-blockstorage-csi-driver/pkg/logger"
2731
mountmanager "github.com/linode/linode-blockstorage-csi-driver/pkg/mount-manager"
28-
"github.com/linode/linodego"
29-
"golang.org/x/net/context"
30-
"k8s.io/mount-utils"
3132
)
3233

3334
type NodeServer struct {
@@ -220,7 +221,7 @@ func (ns *NodeServer) NodeStageVolume(ctx context.Context, req *csi.NodeStageVol
220221

221222
// Check if the volume mode is set to 'Block'
222223
// Do nothing else with the mount point for stage
223-
if blk := req.VolumeCapability.GetBlock(); blk != nil {
224+
if blk := req.GetVolumeCapability().GetBlock(); blk != nil {
224225
log.V(4).Info("Volume is a block volume", "volumeID", volumeID)
225226
return &csi.NodeStageVolumeResponse{}, nil
226227
}
@@ -304,7 +305,7 @@ func (ns *NodeServer) NodeExpandVolume(ctx context.Context, req *csi.NodeExpandV
304305

305306
log.V(2).Info("Successfully completed", "volumeID", volumeID)
306307
return &csi.NodeExpandVolumeResponse{
307-
CapacityBytes: req.CapacityRange.RequiredBytes,
308+
CapacityBytes: req.GetCapacityRange().GetRequiredBytes(),
308309
}, nil
309310
}
310311

0 commit comments

Comments
 (0)