@@ -119,7 +119,7 @@ type testCall func(ctrl *csiSnapshotController, reactor *snapshotReactor, test c
119
119
const testNamespace = "default"
120
120
const mockDriverName = "csi-mock-plugin"
121
121
122
- var versionConflictError = errors .New ("VersionError" )
122
+ var errVersionConflict = errors .New ("VersionError" )
123
123
var nocontents []* crdv1.VolumeSnapshotContent
124
124
var nosnapshots []* crdv1.VolumeSnapshot
125
125
var noevents = []string {}
@@ -228,7 +228,7 @@ func (r *snapshotReactor) React(action core.Action) (handled bool, ret runtime.O
228
228
storedVer , _ := strconv .Atoi (storedVolume .ResourceVersion )
229
229
requestedVer , _ := strconv .Atoi (content .ResourceVersion )
230
230
if storedVer != requestedVer {
231
- return true , obj , versionConflictError
231
+ return true , obj , errVersionConflict
232
232
}
233
233
// Don't modify the existing object
234
234
content = content .DeepCopy ()
@@ -254,7 +254,7 @@ func (r *snapshotReactor) React(action core.Action) (handled bool, ret runtime.O
254
254
storedVer , _ := strconv .Atoi (storedSnapshot .ResourceVersion )
255
255
requestedVer , _ := strconv .Atoi (snapshot .ResourceVersion )
256
256
if storedVer != requestedVer {
257
- return true , obj , versionConflictError
257
+ return true , obj , errVersionConflict
258
258
}
259
259
// Don't modify the existing object
260
260
snapshot = snapshot .DeepCopy ()
@@ -276,21 +276,19 @@ func (r *snapshotReactor) React(action core.Action) (handled bool, ret runtime.O
276
276
if found {
277
277
glog .V (4 ).Infof ("GetVolume: found %s" , content .Name )
278
278
return true , content , nil
279
- } else {
280
- glog .V (4 ).Infof ("GetVolume: content %s not found" , name )
281
- return true , nil , fmt .Errorf ("cannot find content %s" , name )
282
279
}
280
+ glog .V (4 ).Infof ("GetVolume: content %s not found" , name )
281
+ return true , nil , fmt .Errorf ("cannot find content %s" , name )
283
282
284
283
case action .Matches ("get" , "volumesnapshots" ):
285
284
name := action .(core.GetAction ).GetName ()
286
285
snapshot , found := r .snapshots [name ]
287
286
if found {
288
287
glog .V (4 ).Infof ("GetSnapshot: found %s" , snapshot .Name )
289
288
return true , snapshot , nil
290
- } else {
291
- glog .V (4 ).Infof ("GetSnapshot: content %s not found" , name )
292
- return true , nil , fmt .Errorf ("cannot find snapshot %s" , name )
293
289
}
290
+ glog .V (4 ).Infof ("GetSnapshot: content %s not found" , name )
291
+ return true , nil , fmt .Errorf ("cannot find snapshot %s" , name )
294
292
295
293
case action .Matches ("delete" , "volumesnapshotcontents" ):
296
294
name := action .(core.DeleteAction ).GetName ()
@@ -300,9 +298,8 @@ func (r *snapshotReactor) React(action core.Action) (handled bool, ret runtime.O
300
298
delete (r .contents , name )
301
299
r .changedSinceLastSync ++
302
300
return true , nil , nil
303
- } else {
304
- return true , nil , fmt .Errorf ("cannot delete content %s: not found" , name )
305
301
}
302
+ return true , nil , fmt .Errorf ("cannot delete content %s: not found" , name )
306
303
307
304
case action .Matches ("delete" , "volumesnapshots" ):
308
305
name := action .(core.DeleteAction ).GetName ()
@@ -312,53 +309,49 @@ func (r *snapshotReactor) React(action core.Action) (handled bool, ret runtime.O
312
309
delete (r .snapshots , name )
313
310
r .changedSinceLastSync ++
314
311
return true , nil , nil
315
- } else {
316
- return true , nil , fmt .Errorf ("cannot delete snapshot %s: not found" , name )
317
312
}
313
+ return true , nil , fmt .Errorf ("cannot delete snapshot %s: not found" , name )
318
314
319
315
case action .Matches ("get" , "persistentvolumes" ):
320
316
name := action .(core.GetAction ).GetName ()
321
317
volume , found := r .volumes [name ]
322
318
if found {
323
319
glog .V (4 ).Infof ("GetVolume: found %s" , volume .Name )
324
320
return true , volume , nil
325
- } else {
326
- glog .V (4 ).Infof ("GetVolume: volume %s not found" , name )
327
- return true , nil , fmt .Errorf ("cannot find volume %s" , name )
328
321
}
322
+ glog .V (4 ).Infof ("GetVolume: volume %s not found" , name )
323
+ return true , nil , fmt .Errorf ("cannot find volume %s" , name )
329
324
330
325
case action .Matches ("get" , "persistentvolumeclaims" ):
331
326
name := action .(core.GetAction ).GetName ()
332
327
claim , found := r .claims [name ]
333
328
if found {
334
329
glog .V (4 ).Infof ("GetClaim: found %s" , claim .Name )
335
330
return true , claim , nil
336
- } else {
337
- glog .V (4 ).Infof ("GetClaim: claim %s not found" , name )
338
- return true , nil , fmt .Errorf ("cannot find claim %s" , name )
339
331
}
332
+ glog .V (4 ).Infof ("GetClaim: claim %s not found" , name )
333
+ return true , nil , fmt .Errorf ("cannot find claim %s" , name )
340
334
341
335
case action .Matches ("get" , "storageclasses" ):
342
336
name := action .(core.GetAction ).GetName ()
343
337
storageClass , found := r .storageClasses [name ]
344
338
if found {
345
339
glog .V (4 ).Infof ("GetStorageClass: found %s" , storageClass .Name )
346
340
return true , storageClass , nil
347
- } else {
348
- glog .V (4 ).Infof ("GetStorageClass: storageClass %s not found" , name )
349
- return true , nil , fmt .Errorf ("cannot find storageClass %s" , name )
350
341
}
342
+ glog .V (4 ).Infof ("GetStorageClass: storageClass %s not found" , name )
343
+ return true , nil , fmt .Errorf ("cannot find storageClass %s" , name )
351
344
352
345
case action .Matches ("get" , "secrets" ):
353
346
name := action .(core.GetAction ).GetName ()
354
347
secret , found := r .secrets [name ]
355
348
if found {
356
349
glog .V (4 ).Infof ("GetSecret: found %s" , secret .Name )
357
350
return true , secret , nil
358
- } else {
359
- glog .V (4 ).Infof ("GetSecret: secret %s not found" , name )
360
- return true , nil , fmt .Errorf ("cannot find secret %s" , name )
361
351
}
352
+ glog .V (4 ).Infof ("GetSecret: secret %s not found" , name )
353
+ return true , nil , fmt .Errorf ("cannot find secret %s" , name )
354
+
362
355
}
363
356
364
357
return false , nil , nil
@@ -966,16 +959,16 @@ func testSyncContent(ctrl *csiSnapshotController, reactor *snapshotReactor, test
966
959
}
967
960
968
961
var (
969
- classEmpty string = ""
970
- classGold string = "gold"
971
- classSilver string = "silver"
972
- classNonExisting string = "non-existing"
973
- defaultClass string = "default-class"
974
- emptySecretClass string = "empty-secret-class"
975
- invalidSecretClass string = "invalid-secret-class"
976
- validSecretClass string = "valid-secret-class"
977
- sameDriver string = "sameDriver"
978
- diffDriver string = "diffDriver"
962
+ classEmpty string
963
+ classGold = "gold"
964
+ classSilver = "silver"
965
+ classNonExisting = "non-existing"
966
+ defaultClass = "default-class"
967
+ emptySecretClass = "empty-secret-class"
968
+ invalidSecretClass = "invalid-secret-class"
969
+ validSecretClass = "valid-secret-class"
970
+ sameDriver = "sameDriver"
971
+ diffDriver = "diffDriver"
979
972
)
980
973
981
974
// wrapTestWithInjectedOperation returns a testCall that:
0 commit comments