Skip to content

Commit 2deedc0

Browse files
committed
fix lint
1 parent 3a06c70 commit 2deedc0

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

pkg/cloud/cloud.go

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

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

pkg/cloud/fake/fake.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,22 +209,27 @@ func (f *fakeConnector) ListSnapshots(_ context.Context, volumeID, snapshotID st
209209
if snap, ok := f.snapshotsByID[snapshotID]; ok {
210210
result = append(result, snap)
211211
}
212-
213212
return result, nil
214213
}
215214
if volumeID != "" {
215+
count := 0
216+
for _, snap := range f.snapshotsByID {
217+
if snap.VolumeID == volumeID {
218+
count++
219+
}
220+
}
221+
result = make([]*cloud.Snapshot, 0, count)
216222
for _, snap := range f.snapshotsByID {
217223
if snap.VolumeID == volumeID {
218224
result = append(result, snap)
219225
}
220226
}
221-
222227
return result, nil
223228
}
229+
result = make([]*cloud.Snapshot, 0, len(f.snapshotsByID))
224230
for _, snap := range f.snapshotsByID {
225231
result = append(result, snap)
226232
}
227-
228233
return result, nil
229234
}
230235

@@ -241,6 +246,7 @@ func (f *fakeConnector) DeleteSnapshot(_ context.Context, snapshotID string) err
241246
for i, s := range snaps {
242247
if s.ID == snapshotID {
243248
f.snapshotsByName[name] = append(snaps[:i], snaps[i+1:]...)
249+
244250
break
245251
}
246252
}

pkg/cloud/snapshots.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ func (c *client) GetSnapshotByName(ctx context.Context, name string) (*Snapshot,
120120
VolumeID: snapshot.Volumeid,
121121
CreatedAt: snapshot.Created,
122122
}
123+
123124
return &s, nil
124125
}
125126

@@ -147,7 +148,7 @@ func (c *client) ListSnapshots(ctx context.Context, volumeID, snapshotID string)
147148
if l.Count == 0 {
148149
return []*Snapshot{}, nil
149150
}
150-
var result []*Snapshot
151+
result := make([]*Snapshot, 0, l.Count)
151152
for _, snapshot := range l.Snapshots {
152153
s := &Snapshot{
153154
ID: snapshot.Id,

0 commit comments

Comments
 (0)