@@ -139,7 +139,7 @@ func (f *fakeConnector) ExpandVolume(_ context.Context, volumeID string, newSize
139
139
return cloud .ErrNotFound
140
140
}
141
141
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 ) {
143
143
vol := & cloud.Volume {
144
144
ID : "fake-vol-from-snap-" + name ,
145
145
Name : name ,
@@ -149,6 +149,7 @@ func (f *fakeConnector) CreateVolumeFromSnapshot(_ context.Context, zoneID, name
149
149
}
150
150
f .volumesByID [vol .ID ] = * vol
151
151
f .volumesByName [vol .Name ] = * vol
152
+
152
153
return vol , nil
153
154
}
154
155
@@ -161,6 +162,7 @@ func (f *fakeConnector) CreateSnapshot(_ context.Context, volumeID, name string)
161
162
// Allow multiple snapshots with the same name for the same volume
162
163
continue
163
164
}
165
+
164
166
// Name conflict: same name, different volume
165
167
return nil , cloud .ErrAlreadyExists
166
168
}
@@ -175,6 +177,7 @@ func (f *fakeConnector) CreateSnapshot(_ context.Context, volumeID, name string)
175
177
}
176
178
f .snapshotsByID [newSnap .ID ] = newSnap
177
179
f .snapshotsByName [name ] = append (f .snapshotsByName [name ], newSnap )
180
+
178
181
return newSnap , nil
179
182
}
180
183
@@ -183,6 +186,7 @@ func (f *fakeConnector) GetSnapshotByID(_ context.Context, snapshotID string) (*
183
186
if ok {
184
187
return snap , nil
185
188
}
189
+
186
190
return nil , cloud .ErrNotFound
187
191
}
188
192
@@ -194,6 +198,7 @@ func (f *fakeConnector) GetSnapshotByName(_ context.Context, name string) (*clou
194
198
if ok && len (snaps ) > 0 {
195
199
return snaps [0 ], nil // Return the first for compatibility
196
200
}
201
+
197
202
return nil , cloud .ErrNotFound
198
203
}
199
204
@@ -204,6 +209,7 @@ func (f *fakeConnector) ListSnapshots(_ context.Context, volumeID, snapshotID st
204
209
if snap , ok := f .snapshotsByID [snapshotID ]; ok {
205
210
result = append (result , snap )
206
211
}
212
+
207
213
return result , nil
208
214
}
209
215
if volumeID != "" {
@@ -212,11 +218,13 @@ func (f *fakeConnector) ListSnapshots(_ context.Context, volumeID, snapshotID st
212
218
result = append (result , snap )
213
219
}
214
220
}
221
+
215
222
return result , nil
216
223
}
217
224
for _ , snap := range f .snapshotsByID {
218
225
result = append (result , snap )
219
226
}
227
+
220
228
return result , nil
221
229
}
222
230
@@ -225,9 +233,9 @@ func (f *fakeConnector) DeleteSnapshot(_ context.Context, snapshotID string) err
225
233
if ! ok {
226
234
return cloud .ErrNotFound
227
235
}
228
- // Remove from snapshotsByID
236
+
229
237
delete (f .snapshotsByID , snapshotID )
230
- // Remove from snapshotsByName
238
+
231
239
name := snap .Name
232
240
snaps := f .snapshotsByName [name ]
233
241
for i , s := range snaps {
@@ -236,5 +244,6 @@ func (f *fakeConnector) DeleteSnapshot(_ context.Context, snapshotID string) err
236
244
break
237
245
}
238
246
}
247
+
239
248
return nil
240
249
}
0 commit comments