Correct error variables and fix other golint errors.
Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
This commit is contained in:
@@ -104,7 +104,7 @@ func TestGetPluginInfo(t *testing.T) {
|
|||||||
in := &csi.GetPluginInfoRequest{}
|
in := &csi.GetPluginInfoRequest{}
|
||||||
|
|
||||||
out := test.output
|
out := test.output
|
||||||
var injectedErr error = nil
|
var injectedErr error
|
||||||
if test.injectError {
|
if test.injectError {
|
||||||
injectedErr = fmt.Errorf("mock error")
|
injectedErr = fmt.Errorf("mock error")
|
||||||
}
|
}
|
||||||
@@ -214,7 +214,7 @@ func TestSupportsControllerCreateSnapshot(t *testing.T) {
|
|||||||
in := &csi.ControllerGetCapabilitiesRequest{}
|
in := &csi.ControllerGetCapabilitiesRequest{}
|
||||||
|
|
||||||
out := test.output
|
out := test.output
|
||||||
var injectedErr error = nil
|
var injectedErr error
|
||||||
if test.injectError {
|
if test.injectError {
|
||||||
injectedErr = fmt.Errorf("mock error")
|
injectedErr = fmt.Errorf("mock error")
|
||||||
}
|
}
|
||||||
@@ -354,7 +354,7 @@ func TestSupportsControllerListSnapshots(t *testing.T) {
|
|||||||
in := &csi.ControllerGetCapabilitiesRequest{}
|
in := &csi.ControllerGetCapabilitiesRequest{}
|
||||||
|
|
||||||
out := test.output
|
out := test.output
|
||||||
var injectedErr error = nil
|
var injectedErr error
|
||||||
if test.injectError {
|
if test.injectError {
|
||||||
injectedErr = fmt.Errorf("mock error")
|
injectedErr = fmt.Errorf("mock error")
|
||||||
}
|
}
|
||||||
@@ -524,7 +524,7 @@ func TestCreateSnapshot(t *testing.T) {
|
|||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
in := test.input
|
in := test.input
|
||||||
out := test.output
|
out := test.output
|
||||||
var injectedErr error = nil
|
var injectedErr error
|
||||||
if test.injectError != codes.OK {
|
if test.injectError != codes.OK {
|
||||||
injectedErr = status.Error(test.injectError, fmt.Sprintf("Injecting error %d", test.injectError))
|
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 {
|
for _, test := range tests {
|
||||||
in := test.input
|
in := test.input
|
||||||
out := test.output
|
out := test.output
|
||||||
var injectedErr error = nil
|
var injectedErr error
|
||||||
if test.injectError != codes.OK {
|
if test.injectError != codes.OK {
|
||||||
injectedErr = status.Error(test.injectError, fmt.Sprintf("Injecting error %d", test.injectError))
|
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 {
|
for _, test := range tests {
|
||||||
in := test.input
|
in := test.input
|
||||||
out := test.output
|
out := test.output
|
||||||
var injectedErr error = nil
|
var injectedErr error
|
||||||
if test.injectError != codes.OK {
|
if test.injectError != codes.OK {
|
||||||
injectedErr = status.Error(test.injectError, fmt.Sprintf("Injecting error %d", test.injectError))
|
injectedErr = status.Error(test.injectError, fmt.Sprintf("Injecting error %d", test.injectError))
|
||||||
}
|
}
|
||||||
|
@@ -119,7 +119,7 @@ type testCall func(ctrl *csiSnapshotController, reactor *snapshotReactor, test c
|
|||||||
const testNamespace = "default"
|
const testNamespace = "default"
|
||||||
const mockDriverName = "csi-mock-plugin"
|
const mockDriverName = "csi-mock-plugin"
|
||||||
|
|
||||||
var versionConflictError = errors.New("VersionError")
|
var errVersionConflict = errors.New("VersionError")
|
||||||
var nocontents []*crdv1.VolumeSnapshotContent
|
var nocontents []*crdv1.VolumeSnapshotContent
|
||||||
var nosnapshots []*crdv1.VolumeSnapshot
|
var nosnapshots []*crdv1.VolumeSnapshot
|
||||||
var noevents = []string{}
|
var noevents = []string{}
|
||||||
@@ -228,7 +228,7 @@ func (r *snapshotReactor) React(action core.Action) (handled bool, ret runtime.O
|
|||||||
storedVer, _ := strconv.Atoi(storedVolume.ResourceVersion)
|
storedVer, _ := strconv.Atoi(storedVolume.ResourceVersion)
|
||||||
requestedVer, _ := strconv.Atoi(content.ResourceVersion)
|
requestedVer, _ := strconv.Atoi(content.ResourceVersion)
|
||||||
if storedVer != requestedVer {
|
if storedVer != requestedVer {
|
||||||
return true, obj, versionConflictError
|
return true, obj, errVersionConflict
|
||||||
}
|
}
|
||||||
// Don't modify the existing object
|
// Don't modify the existing object
|
||||||
content = content.DeepCopy()
|
content = content.DeepCopy()
|
||||||
@@ -254,7 +254,7 @@ func (r *snapshotReactor) React(action core.Action) (handled bool, ret runtime.O
|
|||||||
storedVer, _ := strconv.Atoi(storedSnapshot.ResourceVersion)
|
storedVer, _ := strconv.Atoi(storedSnapshot.ResourceVersion)
|
||||||
requestedVer, _ := strconv.Atoi(snapshot.ResourceVersion)
|
requestedVer, _ := strconv.Atoi(snapshot.ResourceVersion)
|
||||||
if storedVer != requestedVer {
|
if storedVer != requestedVer {
|
||||||
return true, obj, versionConflictError
|
return true, obj, errVersionConflict
|
||||||
}
|
}
|
||||||
// Don't modify the existing object
|
// Don't modify the existing object
|
||||||
snapshot = snapshot.DeepCopy()
|
snapshot = snapshot.DeepCopy()
|
||||||
@@ -966,16 +966,16 @@ func testSyncContent(ctrl *csiSnapshotController, reactor *snapshotReactor, test
|
|||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
classEmpty string = ""
|
classEmpty string
|
||||||
classGold string = "gold"
|
classGold = "gold"
|
||||||
classSilver string = "silver"
|
classSilver = "silver"
|
||||||
classNonExisting string = "non-existing"
|
classNonExisting = "non-existing"
|
||||||
defaultClass string = "default-class"
|
defaultClass = "default-class"
|
||||||
emptySecretClass string = "empty-secret-class"
|
emptySecretClass = "empty-secret-class"
|
||||||
invalidSecretClass string = "invalid-secret-class"
|
invalidSecretClass = "invalid-secret-class"
|
||||||
validSecretClass string = "valid-secret-class"
|
validSecretClass = "valid-secret-class"
|
||||||
sameDriver string = "sameDriver"
|
sameDriver = "sameDriver"
|
||||||
diffDriver string = "diffDriver"
|
diffDriver = "diffDriver"
|
||||||
)
|
)
|
||||||
|
|
||||||
// wrapTestWithInjectedOperation returns a testCall that:
|
// wrapTestWithInjectedOperation returns a testCall that:
|
||||||
|
@@ -556,9 +556,9 @@ func (ctrl *csiSnapshotController) getCreateSnapshotInput(snapshot *crdv1.Volume
|
|||||||
|
|
||||||
func (ctrl *csiSnapshotController) checkandUpdateBoundSnapshotStatusOperation(snapshot *crdv1.VolumeSnapshot, content *crdv1.VolumeSnapshotContent) (*crdv1.VolumeSnapshot, error) {
|
func (ctrl *csiSnapshotController) checkandUpdateBoundSnapshotStatusOperation(snapshot *crdv1.VolumeSnapshot, content *crdv1.VolumeSnapshotContent) (*crdv1.VolumeSnapshot, error) {
|
||||||
var err error
|
var err error
|
||||||
var timestamp int64 = 0
|
var timestamp int64
|
||||||
var size int64 = 0
|
var size int64
|
||||||
var readyToUse bool = false
|
var readyToUse = false
|
||||||
class, volume, _, snapshotterCredentials, err := ctrl.getCreateSnapshotInput(snapshot)
|
class, volume, _, snapshotterCredentials, err := ctrl.getCreateSnapshotInput(snapshot)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to get input parameters to create snapshot %s: %q", snapshot.Name, err)
|
return nil, fmt.Errorf("failed to get input parameters to create snapshot %s: %q", snapshot.Name, err)
|
||||||
|
@@ -68,7 +68,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var snapshotterSecretParams = deprecatedSecretParamsMap{
|
var snapshotterSecretParams = deprecatedSecretParamsMap{
|
||||||
name: "Snapshotter",
|
name: "Snapshotter",
|
||||||
deprecatedSecretNameKey: snapshotterSecretNameKey,
|
deprecatedSecretNameKey: snapshotterSecretNameKey,
|
||||||
deprecatedSecretNamespaceKey: snapshotterSecretNamespaceKey,
|
deprecatedSecretNamespaceKey: snapshotterSecretNamespaceKey,
|
||||||
secretNameKey: prefixedSnapshotterSecretNameKey,
|
secretNameKey: prefixedSnapshotterSecretNameKey,
|
||||||
@@ -168,21 +168,21 @@ func verifyAndGetSecretNameAndNamespaceTemplate(secret deprecatedSecretParamsMap
|
|||||||
numNamespace := 0
|
numNamespace := 0
|
||||||
if t, ok := snapshotClassParams[secret.deprecatedSecretNameKey]; ok {
|
if t, ok := snapshotClassParams[secret.deprecatedSecretNameKey]; ok {
|
||||||
nameTemplate = t
|
nameTemplate = t
|
||||||
numName += 1
|
numName++
|
||||||
glog.Warning(deprecationWarning(secret.deprecatedSecretNameKey, secret.secretNameKey, ""))
|
glog.Warning(deprecationWarning(secret.deprecatedSecretNameKey, secret.secretNameKey, ""))
|
||||||
}
|
}
|
||||||
if t, ok := snapshotClassParams[secret.deprecatedSecretNamespaceKey]; ok {
|
if t, ok := snapshotClassParams[secret.deprecatedSecretNamespaceKey]; ok {
|
||||||
namespaceTemplate = t
|
namespaceTemplate = t
|
||||||
numNamespace += 1
|
numNamespace++
|
||||||
glog.Warning(deprecationWarning(secret.deprecatedSecretNamespaceKey, secret.secretNamespaceKey, ""))
|
glog.Warning(deprecationWarning(secret.deprecatedSecretNamespaceKey, secret.secretNamespaceKey, ""))
|
||||||
}
|
}
|
||||||
if t, ok := snapshotClassParams[secret.secretNameKey]; ok {
|
if t, ok := snapshotClassParams[secret.secretNameKey]; ok {
|
||||||
nameTemplate = t
|
nameTemplate = t
|
||||||
numName += 1
|
numName++
|
||||||
}
|
}
|
||||||
if t, ok := snapshotClassParams[secret.secretNamespaceKey]; ok {
|
if t, ok := snapshotClassParams[secret.secretNamespaceKey]; ok {
|
||||||
namespaceTemplate = t
|
namespaceTemplate = t
|
||||||
numNamespace += 1
|
numNamespace++
|
||||||
}
|
}
|
||||||
|
|
||||||
if numName > 1 || numNamespace > 1 {
|
if numName > 1 || numNamespace > 1 {
|
||||||
|
Reference in New Issue
Block a user