Correct error variables and fix other golint errors.

Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
This commit is contained in:
Humble Chirammal
2019-01-06 14:31:02 +05:30
parent 9708a1b090
commit 0e4d11b0fb
4 changed files with 27 additions and 27 deletions

View File

@@ -104,7 +104,7 @@ func TestGetPluginInfo(t *testing.T) {
in := &csi.GetPluginInfoRequest{}
out := test.output
var injectedErr error = nil
var injectedErr error
if test.injectError {
injectedErr = fmt.Errorf("mock error")
}
@@ -214,7 +214,7 @@ func TestSupportsControllerCreateSnapshot(t *testing.T) {
in := &csi.ControllerGetCapabilitiesRequest{}
out := test.output
var injectedErr error = nil
var injectedErr error
if test.injectError {
injectedErr = fmt.Errorf("mock error")
}
@@ -354,7 +354,7 @@ func TestSupportsControllerListSnapshots(t *testing.T) {
in := &csi.ControllerGetCapabilitiesRequest{}
out := test.output
var injectedErr error = nil
var injectedErr error
if test.injectError {
injectedErr = fmt.Errorf("mock error")
}
@@ -524,7 +524,7 @@ func TestCreateSnapshot(t *testing.T) {
for _, test := range tests {
in := test.input
out := test.output
var injectedErr error = nil
var injectedErr error
if test.injectError != codes.OK {
injectedErr = status.Error(test.injectError, fmt.Sprintf("Injecting error %d", test.injectError))
}
@@ -632,7 +632,7 @@ func TestDeleteSnapshot(t *testing.T) {
for _, test := range tests {
in := test.input
out := test.output
var injectedErr error = nil
var injectedErr error
if test.injectError != codes.OK {
injectedErr = status.Error(test.injectError, fmt.Sprintf("Injecting error %d", test.injectError))
}
@@ -730,7 +730,7 @@ func TestGetSnapshotStatus(t *testing.T) {
for _, test := range tests {
in := test.input
out := test.output
var injectedErr error = nil
var injectedErr error
if test.injectError != codes.OK {
injectedErr = status.Error(test.injectError, fmt.Sprintf("Injecting error %d", test.injectError))
}

View File

@@ -119,7 +119,7 @@ type testCall func(ctrl *csiSnapshotController, reactor *snapshotReactor, test c
const testNamespace = "default"
const mockDriverName = "csi-mock-plugin"
var versionConflictError = errors.New("VersionError")
var errVersionConflict = errors.New("VersionError")
var nocontents []*crdv1.VolumeSnapshotContent
var nosnapshots []*crdv1.VolumeSnapshot
var noevents = []string{}
@@ -228,7 +228,7 @@ func (r *snapshotReactor) React(action core.Action) (handled bool, ret runtime.O
storedVer, _ := strconv.Atoi(storedVolume.ResourceVersion)
requestedVer, _ := strconv.Atoi(content.ResourceVersion)
if storedVer != requestedVer {
return true, obj, versionConflictError
return true, obj, errVersionConflict
}
// Don't modify the existing object
content = content.DeepCopy()
@@ -254,7 +254,7 @@ func (r *snapshotReactor) React(action core.Action) (handled bool, ret runtime.O
storedVer, _ := strconv.Atoi(storedSnapshot.ResourceVersion)
requestedVer, _ := strconv.Atoi(snapshot.ResourceVersion)
if storedVer != requestedVer {
return true, obj, versionConflictError
return true, obj, errVersionConflict
}
// Don't modify the existing object
snapshot = snapshot.DeepCopy()
@@ -966,16 +966,16 @@ func testSyncContent(ctrl *csiSnapshotController, reactor *snapshotReactor, test
}
var (
classEmpty string = ""
classGold string = "gold"
classSilver string = "silver"
classNonExisting string = "non-existing"
defaultClass string = "default-class"
emptySecretClass string = "empty-secret-class"
invalidSecretClass string = "invalid-secret-class"
validSecretClass string = "valid-secret-class"
sameDriver string = "sameDriver"
diffDriver string = "diffDriver"
classEmpty string
classGold = "gold"
classSilver = "silver"
classNonExisting = "non-existing"
defaultClass = "default-class"
emptySecretClass = "empty-secret-class"
invalidSecretClass = "invalid-secret-class"
validSecretClass = "valid-secret-class"
sameDriver = "sameDriver"
diffDriver = "diffDriver"
)
// wrapTestWithInjectedOperation returns a testCall that:

View File

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

View File

@@ -168,21 +168,21 @@ func verifyAndGetSecretNameAndNamespaceTemplate(secret deprecatedSecretParamsMap
numNamespace := 0
if t, ok := snapshotClassParams[secret.deprecatedSecretNameKey]; ok {
nameTemplate = t
numName += 1
numName++
glog.Warning(deprecationWarning(secret.deprecatedSecretNameKey, secret.secretNameKey, ""))
}
if t, ok := snapshotClassParams[secret.deprecatedSecretNamespaceKey]; ok {
namespaceTemplate = t
numNamespace += 1
numNamespace++
glog.Warning(deprecationWarning(secret.deprecatedSecretNamespaceKey, secret.secretNamespaceKey, ""))
}
if t, ok := snapshotClassParams[secret.secretNameKey]; ok {
nameTemplate = t
numName += 1
numName++
}
if t, ok := snapshotClassParams[secret.secretNamespaceKey]; ok {
namespaceTemplate = t
numNamespace += 1
numNamespace++
}
if numName > 1 || numNamespace > 1 {