@@ -119,7 +119,7 @@ type testCall func(ctrl *csiSnapshotController, reactor *snapshotReactor, test c
119119const testNamespace = "default"
120120const mockDriverName = "csi-mock-plugin"
121121
122- var versionConflictError = errors .New ("VersionError" )
122+ var errVersionConflict = errors .New ("VersionError" )
123123var nocontents []* crdv1.VolumeSnapshotContent
124124var nosnapshots []* crdv1.VolumeSnapshot
125125var noevents = []string {}
@@ -228,7 +228,7 @@ func (r *snapshotReactor) React(action core.Action) (handled bool, ret runtime.O
228228 storedVer , _ := strconv .Atoi (storedVolume .ResourceVersion )
229229 requestedVer , _ := strconv .Atoi (content .ResourceVersion )
230230 if storedVer != requestedVer {
231- return true , obj , versionConflictError
231+ return true , obj , errVersionConflict
232232 }
233233 // Don't modify the existing object
234234 content = content .DeepCopy ()
@@ -254,7 +254,7 @@ func (r *snapshotReactor) React(action core.Action) (handled bool, ret runtime.O
254254 storedVer , _ := strconv .Atoi (storedSnapshot .ResourceVersion )
255255 requestedVer , _ := strconv .Atoi (snapshot .ResourceVersion )
256256 if storedVer != requestedVer {
257- return true , obj , versionConflictError
257+ return true , obj , errVersionConflict
258258 }
259259 // Don't modify the existing object
260260 snapshot = snapshot .DeepCopy ()
@@ -276,21 +276,19 @@ func (r *snapshotReactor) React(action core.Action) (handled bool, ret runtime.O
276276 if found {
277277 glog .V (4 ).Infof ("GetVolume: found %s" , content .Name )
278278 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 )
282279 }
280+ glog .V (4 ).Infof ("GetVolume: content %s not found" , name )
281+ return true , nil , fmt .Errorf ("cannot find content %s" , name )
283282
284283 case action .Matches ("get" , "volumesnapshots" ):
285284 name := action .(core.GetAction ).GetName ()
286285 snapshot , found := r .snapshots [name ]
287286 if found {
288287 glog .V (4 ).Infof ("GetSnapshot: found %s" , snapshot .Name )
289288 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 )
293289 }
290+ glog .V (4 ).Infof ("GetSnapshot: content %s not found" , name )
291+ return true , nil , fmt .Errorf ("cannot find snapshot %s" , name )
294292
295293 case action .Matches ("delete" , "volumesnapshotcontents" ):
296294 name := action .(core.DeleteAction ).GetName ()
@@ -300,9 +298,8 @@ func (r *snapshotReactor) React(action core.Action) (handled bool, ret runtime.O
300298 delete (r .contents , name )
301299 r .changedSinceLastSync ++
302300 return true , nil , nil
303- } else {
304- return true , nil , fmt .Errorf ("cannot delete content %s: not found" , name )
305301 }
302+ return true , nil , fmt .Errorf ("cannot delete content %s: not found" , name )
306303
307304 case action .Matches ("delete" , "volumesnapshots" ):
308305 name := action .(core.DeleteAction ).GetName ()
@@ -312,53 +309,49 @@ func (r *snapshotReactor) React(action core.Action) (handled bool, ret runtime.O
312309 delete (r .snapshots , name )
313310 r .changedSinceLastSync ++
314311 return true , nil , nil
315- } else {
316- return true , nil , fmt .Errorf ("cannot delete snapshot %s: not found" , name )
317312 }
313+ return true , nil , fmt .Errorf ("cannot delete snapshot %s: not found" , name )
318314
319315 case action .Matches ("get" , "persistentvolumes" ):
320316 name := action .(core.GetAction ).GetName ()
321317 volume , found := r .volumes [name ]
322318 if found {
323319 glog .V (4 ).Infof ("GetVolume: found %s" , volume .Name )
324320 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 )
328321 }
322+ glog .V (4 ).Infof ("GetVolume: volume %s not found" , name )
323+ return true , nil , fmt .Errorf ("cannot find volume %s" , name )
329324
330325 case action .Matches ("get" , "persistentvolumeclaims" ):
331326 name := action .(core.GetAction ).GetName ()
332327 claim , found := r .claims [name ]
333328 if found {
334329 glog .V (4 ).Infof ("GetClaim: found %s" , claim .Name )
335330 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 )
339331 }
332+ glog .V (4 ).Infof ("GetClaim: claim %s not found" , name )
333+ return true , nil , fmt .Errorf ("cannot find claim %s" , name )
340334
341335 case action .Matches ("get" , "storageclasses" ):
342336 name := action .(core.GetAction ).GetName ()
343337 storageClass , found := r .storageClasses [name ]
344338 if found {
345339 glog .V (4 ).Infof ("GetStorageClass: found %s" , storageClass .Name )
346340 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 )
350341 }
342+ glog .V (4 ).Infof ("GetStorageClass: storageClass %s not found" , name )
343+ return true , nil , fmt .Errorf ("cannot find storageClass %s" , name )
351344
352345 case action .Matches ("get" , "secrets" ):
353346 name := action .(core.GetAction ).GetName ()
354347 secret , found := r .secrets [name ]
355348 if found {
356349 glog .V (4 ).Infof ("GetSecret: found %s" , secret .Name )
357350 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 )
361351 }
352+ glog .V (4 ).Infof ("GetSecret: secret %s not found" , name )
353+ return true , nil , fmt .Errorf ("cannot find secret %s" , name )
354+
362355 }
363356
364357 return false , nil , nil
@@ -966,16 +959,16 @@ func testSyncContent(ctrl *csiSnapshotController, reactor *snapshotReactor, test
966959}
967960
968961var (
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"
979972)
980973
981974// wrapTestWithInjectedOperation returns a testCall that:
0 commit comments