Skip to content

Commit 3a06c70

Browse files
committed
fix lint
1 parent b0c66eb commit 3a06c70

File tree

6 files changed

+30
-6
lines changed

6 files changed

+30
-6
lines changed

pkg/cloud/cloud.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import (
1010
)
1111

1212
// Interface is the CloudStack client interface.
13+
//
14+
//revive:disable:interfacebloat
1315
type Interface interface {
1416
GetNodeInfo(ctx context.Context, vmName string) (*VM, error)
1517
GetVMByID(ctx context.Context, vmID string) (*VM, error)

pkg/cloud/fake/fake.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func (f *fakeConnector) ExpandVolume(_ context.Context, volumeID string, newSize
139139
return cloud.ErrNotFound
140140
}
141141

142-
func (f *fakeConnector) CreateVolumeFromSnapshot(_ context.Context, zoneID, name, _, snapshotID string, sizeInGB int64) (*cloud.Volume, error) {
142+
func (f *fakeConnector) CreateVolumeFromSnapshot(_ context.Context, zoneID, name, _, _ string, sizeInGB int64) (*cloud.Volume, error) {
143143
vol := &cloud.Volume{
144144
ID: "fake-vol-from-snap-" + name,
145145
Name: name,
@@ -149,6 +149,7 @@ func (f *fakeConnector) CreateVolumeFromSnapshot(_ context.Context, zoneID, name
149149
}
150150
f.volumesByID[vol.ID] = *vol
151151
f.volumesByName[vol.Name] = *vol
152+
152153
return vol, nil
153154
}
154155

@@ -161,6 +162,7 @@ func (f *fakeConnector) CreateSnapshot(_ context.Context, volumeID, name string)
161162
// Allow multiple snapshots with the same name for the same volume
162163
continue
163164
}
165+
164166
// Name conflict: same name, different volume
165167
return nil, cloud.ErrAlreadyExists
166168
}
@@ -175,6 +177,7 @@ func (f *fakeConnector) CreateSnapshot(_ context.Context, volumeID, name string)
175177
}
176178
f.snapshotsByID[newSnap.ID] = newSnap
177179
f.snapshotsByName[name] = append(f.snapshotsByName[name], newSnap)
180+
178181
return newSnap, nil
179182
}
180183

@@ -183,6 +186,7 @@ func (f *fakeConnector) GetSnapshotByID(_ context.Context, snapshotID string) (*
183186
if ok {
184187
return snap, nil
185188
}
189+
186190
return nil, cloud.ErrNotFound
187191
}
188192

@@ -194,6 +198,7 @@ func (f *fakeConnector) GetSnapshotByName(_ context.Context, name string) (*clou
194198
if ok && len(snaps) > 0 {
195199
return snaps[0], nil // Return the first for compatibility
196200
}
201+
197202
return nil, cloud.ErrNotFound
198203
}
199204

@@ -204,6 +209,7 @@ func (f *fakeConnector) ListSnapshots(_ context.Context, volumeID, snapshotID st
204209
if snap, ok := f.snapshotsByID[snapshotID]; ok {
205210
result = append(result, snap)
206211
}
212+
207213
return result, nil
208214
}
209215
if volumeID != "" {
@@ -212,11 +218,13 @@ func (f *fakeConnector) ListSnapshots(_ context.Context, volumeID, snapshotID st
212218
result = append(result, snap)
213219
}
214220
}
221+
215222
return result, nil
216223
}
217224
for _, snap := range f.snapshotsByID {
218225
result = append(result, snap)
219226
}
227+
220228
return result, nil
221229
}
222230

@@ -225,9 +233,9 @@ func (f *fakeConnector) DeleteSnapshot(_ context.Context, snapshotID string) err
225233
if !ok {
226234
return cloud.ErrNotFound
227235
}
228-
// Remove from snapshotsByID
236+
229237
delete(f.snapshotsByID, snapshotID)
230-
// Remove from snapshotsByName
238+
231239
name := snap.Name
232240
snaps := f.snapshotsByName[name]
233241
for i, s := range snaps {
@@ -236,5 +244,6 @@ func (f *fakeConnector) DeleteSnapshot(_ context.Context, snapshotID string) err
236244
break
237245
}
238246
}
247+
239248
return nil
240249
}

pkg/cloud/snapshots.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ func (c *client) CreateSnapshot(ctx context.Context, volumeID, name string) (*Sn
7171
VolumeID: snapshot.Volumeid,
7272
CreatedAt: snapshot.Created,
7373
}
74+
7475
return &snap, nil
7576
}
7677

@@ -160,5 +161,6 @@ func (c *client) ListSnapshots(ctx context.Context, volumeID, snapshotID string)
160161
}
161162
result = append(result, s)
162163
}
164+
163165
return result, nil
164166
}

pkg/cloud/vms.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ func (c *client) GetVMByID(ctx context.Context, vmID string) (*VM, error) {
2929
}
3030
vm := l.VirtualMachines[0]
3131
logger.V(2).Info("Returning VM", "vmID", vm.Id, "zoneID", vm.Zoneid)
32+
3233
return &VM{
3334
ID: vm.Id,
3435
ZoneID: vm.Zoneid,

pkg/driver/controller.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
166166
},
167167
},
168168
}
169+
169170
return resp, nil
170171
}
171172

@@ -226,6 +227,7 @@ func printVolumeAsJSON(vol *csi.CreateVolumeRequest) {
226227
b, err := json.MarshalIndent(vol, "", " ")
227228
if err != nil {
228229
klog.Errorf("Failed to marshal CreateVolumeRequest to JSON: %v", err)
230+
229231
return
230232
}
231233
klog.V(5).Infof("CreateVolumeRequest as JSON:\n%s", string(b))
@@ -347,8 +349,10 @@ func (cs *controllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateS
347349
if errors.Is(err, cloud.ErrNotFound) {
348350
return nil, status.Errorf(codes.NotFound, "Volume %v not found", volumeID)
349351
}
352+
350353
return nil, status.Errorf(codes.Internal, "Error %v", err)
351354
}
355+
352356
klog.V(4).Infof("CreateSnapshot of volume: %s", volume.ID)
353357
snapshot, err := cs.connector.CreateSnapshot(ctx, volume.ID, req.GetName())
354358
if errors.Is(err, cloud.ErrAlreadyExists) {
@@ -372,6 +376,7 @@ func (cs *controllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateS
372376
ReadyToUse: true,
373377
},
374378
}
379+
375380
return resp, nil
376381
}
377382

@@ -385,14 +390,14 @@ func (cs *controllerServer) ListSnapshots(ctx context.Context, req *csi.ListSnap
385390

386391
// Pagination logic
387392
start := 0
388-
if req.StartingToken != "" {
393+
if req.GetStartingToken() != "" {
389394
var err error
390-
start, err = strconv.Atoi(req.StartingToken)
395+
start, err = strconv.Atoi(req.GetStartingToken())
391396
if err != nil || start < 0 || start > len(snapshots) {
392397
return nil, status.Error(codes.Aborted, "Invalid startingToken")
393398
}
394399
}
395-
maxEntries := int(req.MaxEntries)
400+
maxEntries := int(req.GetMaxEntries())
396401
end := len(snapshots)
397402
if maxEntries > 0 && start+maxEntries < end {
398403
end = start + maxEntries
@@ -416,6 +421,7 @@ func (cs *controllerServer) ListSnapshots(ctx context.Context, req *csi.ListSnap
416421
}
417422
entries = append(entries, entry)
418423
}
424+
419425
return &csi.ListSnapshotsResponse{Entries: entries, NextToken: nextToken}, nil
420426
}
421427

pkg/mount/mount.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ func (m *mounter) GetDevicePath(ctx context.Context, volumeID string) (string, e
9595
if path != "" {
9696
devicePath = path
9797
logger.V(4).Info("Device path found", "volumeID", volumeID, "devicePath", path)
98+
9899
return true, nil
99100
}
100101
m.probeVolume(ctx)
@@ -142,6 +143,7 @@ func (m *mounter) getDevicePathBySerialID(ctx context.Context, volumeID string)
142143
}
143144
if !os.IsNotExist(err) {
144145
logger.Error(err, "Failed to stat device path", "path", source)
146+
145147
return "", err
146148
}
147149
}
@@ -161,11 +163,13 @@ func (m *mounter) getDevicePathForXenServer(ctx context.Context, volumeID string
161163
if err == nil && isBlock {
162164
if m.verifyDevice(ctx, devicePath, volumeID) {
163165
logger.V(4).Info("Found and verified XenServer device", "devicePath", devicePath, "volumeID", volumeID)
166+
164167
return devicePath, nil
165168
}
166169
}
167170
}
168171
}
172+
169173
return "", fmt.Errorf("device not found for volume %s", volumeID)
170174
}
171175

0 commit comments

Comments
 (0)