Skip to content

Commit 0e4d11b

Browse files
committed
Correct error variables and fix other golint errors.
Signed-off-by: Humble Chirammal <[email protected]>
1 parent 9708a1b commit 0e4d11b

File tree

4 files changed

+27
-27
lines changed

4 files changed

+27
-27
lines changed

pkg/connection/connection_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func TestGetPluginInfo(t *testing.T) {
104104
in := &csi.GetPluginInfoRequest{}
105105

106106
out := test.output
107-
var injectedErr error = nil
107+
var injectedErr error
108108
if test.injectError {
109109
injectedErr = fmt.Errorf("mock error")
110110
}
@@ -214,7 +214,7 @@ func TestSupportsControllerCreateSnapshot(t *testing.T) {
214214
in := &csi.ControllerGetCapabilitiesRequest{}
215215

216216
out := test.output
217-
var injectedErr error = nil
217+
var injectedErr error
218218
if test.injectError {
219219
injectedErr = fmt.Errorf("mock error")
220220
}
@@ -354,7 +354,7 @@ func TestSupportsControllerListSnapshots(t *testing.T) {
354354
in := &csi.ControllerGetCapabilitiesRequest{}
355355

356356
out := test.output
357-
var injectedErr error = nil
357+
var injectedErr error
358358
if test.injectError {
359359
injectedErr = fmt.Errorf("mock error")
360360
}
@@ -524,7 +524,7 @@ func TestCreateSnapshot(t *testing.T) {
524524
for _, test := range tests {
525525
in := test.input
526526
out := test.output
527-
var injectedErr error = nil
527+
var injectedErr error
528528
if test.injectError != codes.OK {
529529
injectedErr = status.Error(test.injectError, fmt.Sprintf("Injecting error %d", test.injectError))
530530
}
@@ -632,7 +632,7 @@ func TestDeleteSnapshot(t *testing.T) {
632632
for _, test := range tests {
633633
in := test.input
634634
out := test.output
635-
var injectedErr error = nil
635+
var injectedErr error
636636
if test.injectError != codes.OK {
637637
injectedErr = status.Error(test.injectError, fmt.Sprintf("Injecting error %d", test.injectError))
638638
}
@@ -730,7 +730,7 @@ func TestGetSnapshotStatus(t *testing.T) {
730730
for _, test := range tests {
731731
in := test.input
732732
out := test.output
733-
var injectedErr error = nil
733+
var injectedErr error
734734
if test.injectError != codes.OK {
735735
injectedErr = status.Error(test.injectError, fmt.Sprintf("Injecting error %d", test.injectError))
736736
}

pkg/controller/framework_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ type testCall func(ctrl *csiSnapshotController, reactor *snapshotReactor, test c
119119
const testNamespace = "default"
120120
const mockDriverName = "csi-mock-plugin"
121121

122-
var versionConflictError = errors.New("VersionError")
122+
var errVersionConflict = errors.New("VersionError")
123123
var nocontents []*crdv1.VolumeSnapshotContent
124124
var nosnapshots []*crdv1.VolumeSnapshot
125125
var 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()
@@ -966,16 +966,16 @@ func testSyncContent(ctrl *csiSnapshotController, reactor *snapshotReactor, test
966966
}
967967

968968
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"
969+
classEmpty string
970+
classGold = "gold"
971+
classSilver = "silver"
972+
classNonExisting = "non-existing"
973+
defaultClass = "default-class"
974+
emptySecretClass = "empty-secret-class"
975+
invalidSecretClass = "invalid-secret-class"
976+
validSecretClass = "valid-secret-class"
977+
sameDriver = "sameDriver"
978+
diffDriver = "diffDriver"
979979
)
980980

981981
// wrapTestWithInjectedOperation returns a testCall that:

pkg/controller/snapshot_controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -556,9 +556,9 @@ func (ctrl *csiSnapshotController) getCreateSnapshotInput(snapshot *crdv1.Volume
556556

557557
func (ctrl *csiSnapshotController) checkandUpdateBoundSnapshotStatusOperation(snapshot *crdv1.VolumeSnapshot, content *crdv1.VolumeSnapshotContent) (*crdv1.VolumeSnapshot, error) {
558558
var err error
559-
var timestamp int64 = 0
560-
var size int64 = 0
561-
var readyToUse bool = false
559+
var timestamp int64
560+
var size int64
561+
var readyToUse = false
562562
class, volume, _, snapshotterCredentials, err := ctrl.getCreateSnapshotInput(snapshot)
563563
if err != nil {
564564
return nil, fmt.Errorf("failed to get input parameters to create snapshot %s: %q", snapshot.Name, err)

pkg/controller/util.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ const (
6868
)
6969

7070
var snapshotterSecretParams = deprecatedSecretParamsMap{
71-
name: "Snapshotter",
71+
name: "Snapshotter",
7272
deprecatedSecretNameKey: snapshotterSecretNameKey,
7373
deprecatedSecretNamespaceKey: snapshotterSecretNamespaceKey,
7474
secretNameKey: prefixedSnapshotterSecretNameKey,
@@ -168,21 +168,21 @@ func verifyAndGetSecretNameAndNamespaceTemplate(secret deprecatedSecretParamsMap
168168
numNamespace := 0
169169
if t, ok := snapshotClassParams[secret.deprecatedSecretNameKey]; ok {
170170
nameTemplate = t
171-
numName += 1
171+
numName++
172172
glog.Warning(deprecationWarning(secret.deprecatedSecretNameKey, secret.secretNameKey, ""))
173173
}
174174
if t, ok := snapshotClassParams[secret.deprecatedSecretNamespaceKey]; ok {
175175
namespaceTemplate = t
176-
numNamespace += 1
176+
numNamespace++
177177
glog.Warning(deprecationWarning(secret.deprecatedSecretNamespaceKey, secret.secretNamespaceKey, ""))
178178
}
179179
if t, ok := snapshotClassParams[secret.secretNameKey]; ok {
180180
nameTemplate = t
181-
numName += 1
181+
numName++
182182
}
183183
if t, ok := snapshotClassParams[secret.secretNamespaceKey]; ok {
184184
namespaceTemplate = t
185-
numNamespace += 1
185+
numNamespace++
186186
}
187187

188188
if numName > 1 || numNamespace > 1 {

0 commit comments

Comments
 (0)