Merge pull request #101115 from wangyx1992/capital-log

cleanup: fix log capitalization in volume package
This commit is contained in:
Kubernetes Prow Robot 2021-05-06 03:51:16 -07:00 committed by GitHub
commit 4ad08fa5b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
49 changed files with 170 additions and 170 deletions

View File

@ -79,8 +79,8 @@ func TestAttachDetach(t *testing.T) {
diskName := aws.KubernetesVolumeID("disk") diskName := aws.KubernetesVolumeID("disk")
nodeName := types.NodeName("instance") nodeName := types.NodeName("instance")
spec := createVolSpec(diskName, false) spec := createVolSpec(diskName, false)
attachError := errors.New("Fake attach error") attachError := errors.New("fake attach error")
detachError := errors.New("Fake detach error") detachError := errors.New("fake detach error")
tests := []testcase{ tests := []testcase{
// Successful Attach call // Successful Attach call
{ {
@ -220,12 +220,12 @@ func (testcase *testcase) AttachDisk(diskName aws.KubernetesVolumeID, nodeName t
if expected.diskName != diskName { if expected.diskName != diskName {
testcase.t.Errorf("Unexpected AttachDisk call: expected diskName %s, got %s", expected.diskName, diskName) testcase.t.Errorf("Unexpected AttachDisk call: expected diskName %s, got %s", expected.diskName, diskName)
return "", errors.New("Unexpected AttachDisk call: wrong diskName") return "", errors.New("unexpected AttachDisk call: wrong diskName")
} }
if expected.nodeName != nodeName { if expected.nodeName != nodeName {
testcase.t.Errorf("Unexpected AttachDisk call: expected nodeName %s, got %s", expected.nodeName, nodeName) testcase.t.Errorf("Unexpected AttachDisk call: expected nodeName %s, got %s", expected.nodeName, nodeName)
return "", errors.New("Unexpected AttachDisk call: wrong nodeName") return "", errors.New("unexpected AttachDisk call: wrong nodeName")
} }
klog.V(4).Infof("AttachDisk call: %s, %s, returning %q, %v", diskName, nodeName, expected.retDeviceName, expected.ret) klog.V(4).Infof("AttachDisk call: %s, %s, returning %q, %v", diskName, nodeName, expected.retDeviceName, expected.ret)
@ -245,12 +245,12 @@ func (testcase *testcase) DetachDisk(diskName aws.KubernetesVolumeID, nodeName t
if expected.diskName != diskName { if expected.diskName != diskName {
testcase.t.Errorf("Unexpected DetachDisk call: expected diskName %s, got %s", expected.diskName, diskName) testcase.t.Errorf("Unexpected DetachDisk call: expected diskName %s, got %s", expected.diskName, diskName)
return "", errors.New("Unexpected DetachDisk call: wrong diskName") return "", errors.New("unexpected DetachDisk call: wrong diskName")
} }
if expected.nodeName != nodeName { if expected.nodeName != nodeName {
testcase.t.Errorf("Unexpected DetachDisk call: expected nodeName %s, got %s", expected.nodeName, nodeName) testcase.t.Errorf("Unexpected DetachDisk call: expected nodeName %s, got %s", expected.nodeName, nodeName)
return "", errors.New("Unexpected DetachDisk call: wrong nodeName") return "", errors.New("unexpected DetachDisk call: wrong nodeName")
} }
klog.V(4).Infof("DetachDisk call: %s, %s, returning %q, %v", diskName, nodeName, expected.retDeviceName, expected.ret) klog.V(4).Infof("DetachDisk call: %s, %s, returning %q, %v", diskName, nodeName, expected.retDeviceName, expected.ret)
@ -264,28 +264,28 @@ func (testcase *testcase) DiskIsAttached(diskName aws.KubernetesVolumeID, nodeNa
} }
func (testcase *testcase) DisksAreAttached(nodeDisks map[types.NodeName][]aws.KubernetesVolumeID) (map[types.NodeName]map[aws.KubernetesVolumeID]bool, error) { func (testcase *testcase) DisksAreAttached(nodeDisks map[types.NodeName][]aws.KubernetesVolumeID) (map[types.NodeName]map[aws.KubernetesVolumeID]bool, error) {
return nil, errors.New("Not implemented") return nil, errors.New("not implemented")
} }
func (testcase *testcase) CreateDisk(volumeOptions *aws.VolumeOptions) (volumeName aws.KubernetesVolumeID, err error) { func (testcase *testcase) CreateDisk(volumeOptions *aws.VolumeOptions) (volumeName aws.KubernetesVolumeID, err error) {
return "", errors.New("Not implemented") return "", errors.New("not implemented")
} }
func (testcase *testcase) DeleteDisk(volumeName aws.KubernetesVolumeID) (bool, error) { func (testcase *testcase) DeleteDisk(volumeName aws.KubernetesVolumeID) (bool, error) {
return false, errors.New("Not implemented") return false, errors.New("not implemented")
} }
func (testcase *testcase) GetVolumeLabels(volumeName aws.KubernetesVolumeID) (map[string]string, error) { func (testcase *testcase) GetVolumeLabels(volumeName aws.KubernetesVolumeID) (map[string]string, error) {
return map[string]string{}, errors.New("Not implemented") return map[string]string{}, errors.New("not implemented")
} }
func (testcase *testcase) GetDiskPath(volumeName aws.KubernetesVolumeID) (string, error) { func (testcase *testcase) GetDiskPath(volumeName aws.KubernetesVolumeID) (string, error) {
return "", errors.New("Not implemented") return "", errors.New("not implemented")
} }
func (testcase *testcase) ResizeDisk( func (testcase *testcase) ResizeDisk(
volumeName aws.KubernetesVolumeID, volumeName aws.KubernetesVolumeID,
oldSize resource.Quantity, oldSize resource.Quantity,
newSize resource.Quantity) (resource.Quantity, error) { newSize resource.Quantity) (resource.Quantity, error) {
return oldSize, errors.New("Not implemented") return oldSize, errors.New("not implemented")
} }

View File

@ -110,11 +110,11 @@ func (plugin *awsElasticBlockStorePlugin) GetVolumeLimits() (map[string]int64, e
// default values from here will mean, no one can // default values from here will mean, no one can
// override them. // override them.
if cloud == nil { if cloud == nil {
return nil, fmt.Errorf("No cloudprovider present") return nil, fmt.Errorf("no cloudprovider present")
} }
if cloud.ProviderName() != aws.ProviderName { if cloud.ProviderName() != aws.ProviderName {
return nil, fmt.Errorf("Expected aws cloud, found %s", cloud.ProviderName()) return nil, fmt.Errorf("expected aws cloud, found %s", cloud.ProviderName())
} }
instances, ok := cloud.Instances() instances, ok := cloud.Instances()

View File

@ -204,7 +204,7 @@ func populateVolumeOptions(pluginName, pvcName string, capacityGB resource.Quant
func verifyDevicePath(devicePaths []string) (string, error) { func verifyDevicePath(devicePaths []string) (string, error) {
for _, path := range devicePaths { for _, path := range devicePaths {
if pathExists, err := mount.PathExists(path); err != nil { if pathExists, err := mount.PathExists(path); err != nil {
return "", fmt.Errorf("Error checking if path exists: %v", err) return "", fmt.Errorf("error checking if path exists: %v", err)
} else if pathExists { } else if pathExists {
return path, nil return path, nil
} }
@ -255,7 +255,7 @@ func getDiskByIDPaths(volumeID aws.KubernetesVolumeID, partition string, deviceP
func getCloudProvider(cloudProvider cloudprovider.Interface) (*aws.Cloud, error) { func getCloudProvider(cloudProvider cloudprovider.Interface) (*aws.Cloud, error) {
awsCloudProvider, ok := cloudProvider.(*aws.Cloud) awsCloudProvider, ok := cloudProvider.(*aws.Cloud)
if !ok || awsCloudProvider == nil { if !ok || awsCloudProvider == nil {
return nil, fmt.Errorf("Failed to get AWS Cloud Provider. GetCloudProvider returned %v instead", cloudProvider) return nil, fmt.Errorf("failed to get AWS Cloud Provider. GetCloudProvider returned %v instead", cloudProvider)
} }
return awsCloudProvider, nil return awsCloudProvider, nil
@ -310,7 +310,7 @@ func formatVolumeID(volumeID string) (string, error) {
} }
volName := names[length-1] volName := names[length-1]
if !strings.HasPrefix(volName, "vol-") { if !strings.HasPrefix(volName, "vol-") {
return "", fmt.Errorf("Invalid volume name format for AWS volume (%q)", volName) return "", fmt.Errorf("invalid volume name format for AWS volume (%q)", volName)
} }
if length == 2 { if length == 2 {
sourceName = awsURLNamePrefix + "" + "/" + volName // empty zone label sourceName = awsURLNamePrefix + "" + "/" + volName // empty zone label

View File

@ -397,7 +397,7 @@ func getSecretNameAndNamespace(spec *volume.Spec, defaultNamespace string) (stri
func getAzureCloud(cloudProvider cloudprovider.Interface) (*azure.Cloud, error) { func getAzureCloud(cloudProvider cloudprovider.Interface) (*azure.Cloud, error) {
azure, ok := cloudProvider.(*azure.Cloud) azure, ok := cloudProvider.(*azure.Cloud)
if !ok || azure == nil { if !ok || azure == nil {
return nil, fmt.Errorf("Failed to get Azure Cloud Provider. GetCloudProvider returned %v instead", cloudProvider) return nil, fmt.Errorf("failed to get Azure Cloud Provider. GetCloudProvider returned %v instead", cloudProvider)
} }
return azure, nil return azure, nil

View File

@ -277,7 +277,7 @@ func (a *azureFileProvisioner) Provision(selectedNode *v1.Node, allowedTopologie
func getAzureCloudProvider(cloudProvider cloudprovider.Interface) (azureCloudProvider, string, error) { func getAzureCloudProvider(cloudProvider cloudprovider.Interface) (azureCloudProvider, string, error) {
azureCloudProvider, ok := cloudProvider.(*azure.Cloud) azureCloudProvider, ok := cloudProvider.(*azure.Cloud)
if !ok || azureCloudProvider == nil { if !ok || azureCloudProvider == nil {
return nil, "", fmt.Errorf("Failed to get Azure Cloud Provider. GetCloudProvider returned %v instead", cloudProvider) return nil, "", fmt.Errorf("failed to get Azure Cloud Provider. GetCloudProvider returned %v instead", cloudProvider)
} }
return azureCloudProvider, azureCloudProvider.ResourceGroup, nil return azureCloudProvider, azureCloudProvider.ResourceGroup, nil

View File

@ -54,12 +54,12 @@ func (s *azureSvc) GetAzureCredentials(host volume.VolumeHost, nameSpace, secret
var accountKey, accountName string var accountKey, accountName string
kubeClient := host.GetKubeClient() kubeClient := host.GetKubeClient()
if kubeClient == nil { if kubeClient == nil {
return "", "", fmt.Errorf("Cannot get kube client") return "", "", fmt.Errorf("cannot get kube client")
} }
keys, err := kubeClient.CoreV1().Secrets(nameSpace).Get(context.TODO(), secretName, metav1.GetOptions{}) keys, err := kubeClient.CoreV1().Secrets(nameSpace).Get(context.TODO(), secretName, metav1.GetOptions{})
if err != nil { if err != nil {
return "", "", fmt.Errorf("Couldn't get secret %v/%v", nameSpace, secretName) return "", "", fmt.Errorf("couldn't get secret %v/%v", nameSpace, secretName)
} }
for name, data := range keys.Data { for name, data := range keys.Data {
if name == "azurestorageaccountname" { if name == "azurestorageaccountname" {
@ -70,7 +70,7 @@ func (s *azureSvc) GetAzureCredentials(host volume.VolumeHost, nameSpace, secret
} }
} }
if accountName == "" || accountKey == "" { if accountName == "" || accountKey == "" {
return "", "", fmt.Errorf("Invalid %v/%v, couldn't extract azurestorageaccountname or azurestorageaccountkey", nameSpace, secretName) return "", "", fmt.Errorf("invalid %v/%v, couldn't extract azurestorageaccountname or azurestorageaccountkey", nameSpace, secretName)
} }
accountName = strings.TrimSpace(accountName) accountName = strings.TrimSpace(accountName)
return accountName, accountKey, nil return accountName, accountKey, nil
@ -79,7 +79,7 @@ func (s *azureSvc) GetAzureCredentials(host volume.VolumeHost, nameSpace, secret
func (s *azureSvc) SetAzureCredentials(host volume.VolumeHost, nameSpace, accountName, accountKey string) (string, error) { func (s *azureSvc) SetAzureCredentials(host volume.VolumeHost, nameSpace, accountName, accountKey string) (string, error) {
kubeClient := host.GetKubeClient() kubeClient := host.GetKubeClient()
if kubeClient == nil { if kubeClient == nil {
return "", fmt.Errorf("Cannot get kube client") return "", fmt.Errorf("cannot get kube client")
} }
secretName := "azure-storage-account-" + accountName + "-secret" secretName := "azure-storage-account-" + accountName + "-secret"
secret := &v1.Secret{ secret := &v1.Secret{
@ -98,7 +98,7 @@ func (s *azureSvc) SetAzureCredentials(host volume.VolumeHost, nameSpace, accoun
err = nil err = nil
} }
if err != nil { if err != nil {
return "", fmt.Errorf("Couldn't create secret %v", err) return "", fmt.Errorf("couldn't create secret %v", err)
} }
return secretName, err return secretName, err
} }

View File

@ -176,7 +176,7 @@ func (u *azureDiskUnmounter) TearDown() error {
func (u *azureDiskUnmounter) TearDownAt(dir string) error { func (u *azureDiskUnmounter) TearDownAt(dir string) error {
if pathExists, pathErr := mount.PathExists(dir); pathErr != nil { if pathExists, pathErr := mount.PathExists(dir); pathErr != nil {
return fmt.Errorf("Error checking if path exists: %v", pathErr) return fmt.Errorf("error checking if path exists: %w", pathErr)
} else if !pathExists { } else if !pathExists {
klog.Warningf("Warning: Unmount skipped because path does not exist: %v", dir) klog.Warningf("Warning: Unmount skipped because path does not exist: %v", dir)
return nil return nil

View File

@ -103,11 +103,11 @@ func (plugin *cephfsPlugin) NewMounter(spec *volume.Spec, pod *v1.Pod, _ volume.
// if secret is provideded, retrieve it // if secret is provideded, retrieve it
kubeClient := plugin.host.GetKubeClient() kubeClient := plugin.host.GetKubeClient()
if kubeClient == nil { if kubeClient == nil {
return nil, fmt.Errorf("Cannot get kube client") return nil, fmt.Errorf("cannot get kube client")
} }
secrets, err := kubeClient.CoreV1().Secrets(secretNs).Get(context.TODO(), secretName, metav1.GetOptions{}) secrets, err := kubeClient.CoreV1().Secrets(secretNs).Get(context.TODO(), secretName, metav1.GetOptions{})
if err != nil { if err != nil {
err = fmt.Errorf("Couldn't get secret %v/%v err: %v", secretNs, secretName, err) err = fmt.Errorf("couldn't get secret %v/%v err: %w", secretNs, secretName, err)
return nil, err return nil, err
} }
for name, data := range secrets.Data { for name, data := range secrets.Data {

View File

@ -102,7 +102,7 @@ func (attacher *cinderDiskAttacher) waitOperationFinished(volumeID string) error
}) })
if err == wait.ErrWaitTimeout { if err == wait.ErrWaitTimeout {
err = fmt.Errorf("Volume %q is %s, can't finish within the alloted time", volumeID, volumeStatus) err = fmt.Errorf("volume %q is %s, can't finish within the alloted time", volumeID, volumeStatus)
} }
return err return err
@ -124,7 +124,7 @@ func (attacher *cinderDiskAttacher) waitDiskAttached(instanceID, volumeID string
}) })
if err == wait.ErrWaitTimeout { if err == wait.ErrWaitTimeout {
err = fmt.Errorf("Volume %q failed to be attached within the alloted time", volumeID) err = fmt.Errorf("volume %q failed to be attached within the alloted time", volumeID)
} }
return err return err
@ -346,7 +346,7 @@ func (detacher *cinderDiskDetacher) waitOperationFinished(volumeID string) error
}) })
if err == wait.ErrWaitTimeout { if err == wait.ErrWaitTimeout {
err = fmt.Errorf("Volume %q is %s, can't finish within the alloted time", volumeID, volumeStatus) err = fmt.Errorf("volume %q is %s, can't finish within the alloted time", volumeID, volumeStatus)
} }
return err return err
@ -368,7 +368,7 @@ func (detacher *cinderDiskDetacher) waitDiskDetached(instanceID, volumeID string
}) })
if err == wait.ErrWaitTimeout { if err == wait.ErrWaitTimeout {
err = fmt.Errorf("Volume %q failed to detach within the alloted time", volumeID) err = fmt.Errorf("volume %q failed to detach within the alloted time", volumeID)
} }
return err return err

View File

@ -123,12 +123,12 @@ func TestAttachDetach(t *testing.T) {
nodeName := types.NodeName("nodeName") nodeName := types.NodeName("nodeName")
readOnly := false readOnly := false
spec := createVolSpec(volumeID, readOnly) spec := createVolSpec(volumeID, readOnly)
attachError := errors.New("Fake attach error") attachError := errors.New("fake attach error")
detachError := errors.New("Fake detach error") detachError := errors.New("fake detach error")
diskCheckError := errors.New("Fake DiskIsAttached error") diskCheckError := errors.New("fake DiskIsAttached error")
diskPathError := errors.New("Fake GetAttachmentDiskPath error") diskPathError := errors.New("fake GetAttachmentDiskPath error")
disksCheckError := errors.New("Fake DisksAreAttached error") disksCheckError := errors.New("fake DisksAreAttached error")
operationFinishTimeout := errors.New("Fake waitOperationFinished error") operationFinishTimeout := errors.New("fake waitOperationFinished error")
tests := []testcase{ tests := []testcase{
// Successful Attach call // Successful Attach call
{ {
@ -618,7 +618,7 @@ func (testcase *testcase) DiskIsAttachedByName(nodeName types.NodeName, volumeID
} }
func (testcase *testcase) CreateVolume(name string, size int, vtype, availability string, tags *map[string]string) (string, string, string, bool, error) { func (testcase *testcase) CreateVolume(name string, size int, vtype, availability string, tags *map[string]string) (string, string, string, bool, error) {
return "", "", "", false, errors.New("Not implemented") return "", "", "", false, errors.New("not implemented")
} }
func (testcase *testcase) GetDevicePath(volumeID string) string { func (testcase *testcase) GetDevicePath(volumeID string) string {
@ -634,11 +634,11 @@ func (testcase *testcase) ExpandVolume(volumeID string, oldSize resource.Quantit
} }
func (testcase *testcase) DeleteVolume(volumeID string) error { func (testcase *testcase) DeleteVolume(volumeID string) error {
return errors.New("Not implemented") return errors.New("not implemented")
} }
func (testcase *testcase) GetAutoLabelsForPD(name string) (map[string]string, error) { func (testcase *testcase) GetAutoLabelsForPD(name string) (map[string]string, error) {
return map[string]string{}, errors.New("Not implemented") return map[string]string{}, errors.New("not implemented")
} }
func (testcase *testcase) Instances() (cloudprovider.Instances, bool) { func (testcase *testcase) Instances() (cloudprovider.Instances, bool) {
@ -657,17 +657,17 @@ func (testcase *testcase) DisksAreAttached(instanceID string, volumeIDs []string
if len(expected.volumeIDs) == 0 && expected.instanceID == "" { if len(expected.volumeIDs) == 0 && expected.instanceID == "" {
// testcase.volumeIDs looks uninitialized, test did not expect to call DisksAreAttached // testcase.volumeIDs looks uninitialized, test did not expect to call DisksAreAttached
testcase.t.Errorf("Unexpected DisksAreAttached call!") testcase.t.Errorf("Unexpected DisksAreAttached call!")
return areAttached, errors.New("Unexpected DisksAreAttached call") return areAttached, errors.New("unexpected DisksAreAttached call")
} }
if !reflect.DeepEqual(expected.volumeIDs, volumeIDs) { if !reflect.DeepEqual(expected.volumeIDs, volumeIDs) {
testcase.t.Errorf("Unexpected DisksAreAttached call: expected volumeIDs %v, got %v", expected.volumeIDs, volumeIDs) testcase.t.Errorf("Unexpected DisksAreAttached call: expected volumeIDs %v, got %v", expected.volumeIDs, volumeIDs)
return areAttached, errors.New("Unexpected DisksAreAttached call: wrong volumeID") return areAttached, errors.New("unexpected DisksAreAttached call: wrong volumeID")
} }
if expected.instanceID != instanceID { if expected.instanceID != instanceID {
testcase.t.Errorf("Unexpected DisksAreAttached call: expected instanceID %s, got %s", expected.instanceID, instanceID) testcase.t.Errorf("Unexpected DisksAreAttached call: expected instanceID %s, got %s", expected.instanceID, instanceID)
return areAttached, errors.New("Unexpected DisksAreAttached call: wrong instanceID") return areAttached, errors.New("unexpected DisksAreAttached call: wrong instanceID")
} }
klog.V(4).Infof("DisksAreAttached call: %v, %s, returning %v, %v", volumeIDs, instanceID, expected.areAttached, expected.ret) klog.V(4).Infof("DisksAreAttached call: %v, %s, returning %v, %v", volumeIDs, instanceID, expected.areAttached, expected.ret)
@ -682,22 +682,22 @@ func (testcase *testcase) DisksAreAttachedByName(nodeName types.NodeName, volume
instanceID := expected.instanceID instanceID := expected.instanceID
if expected.nodeName != nodeName { if expected.nodeName != nodeName {
testcase.t.Errorf("Unexpected DisksAreAttachedByName call: expected nodeName %s, got %s", expected.nodeName, nodeName) testcase.t.Errorf("Unexpected DisksAreAttachedByName call: expected nodeName %s, got %s", expected.nodeName, nodeName)
return areAttached, errors.New("Unexpected DisksAreAttachedByName call: wrong nodename") return areAttached, errors.New("unexpected DisksAreAttachedByName call: wrong nodename")
} }
if len(expected.volumeIDs) == 0 && expected.instanceID == "" { if len(expected.volumeIDs) == 0 && expected.instanceID == "" {
// testcase.volumeIDs looks uninitialized, test did not expect to call DisksAreAttached // testcase.volumeIDs looks uninitialized, test did not expect to call DisksAreAttached
testcase.t.Errorf("Unexpected DisksAreAttachedByName call!") testcase.t.Errorf("Unexpected DisksAreAttachedByName call!")
return areAttached, errors.New("Unexpected DisksAreAttachedByName call") return areAttached, errors.New("unexpected DisksAreAttachedByName call")
} }
if !reflect.DeepEqual(expected.volumeIDs, volumeIDs) { if !reflect.DeepEqual(expected.volumeIDs, volumeIDs) {
testcase.t.Errorf("Unexpected DisksAreAttachedByName call: expected volumeIDs %v, got %v", expected.volumeIDs, volumeIDs) testcase.t.Errorf("Unexpected DisksAreAttachedByName call: expected volumeIDs %v, got %v", expected.volumeIDs, volumeIDs)
return areAttached, errors.New("Unexpected DisksAreAttachedByName call: wrong volumeID") return areAttached, errors.New("unexpected DisksAreAttachedByName call: wrong volumeID")
} }
if expected.instanceID != instanceID { if expected.instanceID != instanceID {
testcase.t.Errorf("Unexpected DisksAreAttachedByName call: expected instanceID %s, got %s", expected.instanceID, instanceID) testcase.t.Errorf("Unexpected DisksAreAttachedByName call: expected instanceID %s, got %s", expected.instanceID, instanceID)
return areAttached, errors.New("Unexpected DisksAreAttachedByName call: wrong instanceID") return areAttached, errors.New("unexpected DisksAreAttachedByName call: wrong instanceID")
} }
klog.V(4).Infof("DisksAreAttachedByName call: %v, %s, returning %v, %v", volumeIDs, nodeName, expected.areAttached, expected.ret) klog.V(4).Infof("DisksAreAttachedByName call: %v, %s, returning %v, %v", volumeIDs, nodeName, expected.areAttached, expected.ret)
@ -711,11 +711,11 @@ type instances struct {
} }
func (instances *instances) NodeAddresses(ctx context.Context, name types.NodeName) ([]v1.NodeAddress, error) { func (instances *instances) NodeAddresses(ctx context.Context, name types.NodeName) ([]v1.NodeAddress, error) {
return []v1.NodeAddress{}, errors.New("Not implemented") return []v1.NodeAddress{}, errors.New("not implemented")
} }
func (instances *instances) NodeAddressesByProviderID(ctx context.Context, providerID string) ([]v1.NodeAddress, error) { func (instances *instances) NodeAddressesByProviderID(ctx context.Context, providerID string) ([]v1.NodeAddress, error) {
return []v1.NodeAddress{}, errors.New("Not implemented") return []v1.NodeAddress{}, errors.New("not implemented")
} }
func (instances *instances) InstanceID(ctx context.Context, name types.NodeName) (string, error) { func (instances *instances) InstanceID(ctx context.Context, name types.NodeName) (string, error) {
@ -723,11 +723,11 @@ func (instances *instances) InstanceID(ctx context.Context, name types.NodeName)
} }
func (instances *instances) InstanceType(ctx context.Context, name types.NodeName) (string, error) { func (instances *instances) InstanceType(ctx context.Context, name types.NodeName) (string, error) {
return "", errors.New("Not implemented") return "", errors.New("not implemented")
} }
func (instances *instances) InstanceTypeByProviderID(ctx context.Context, providerID string) (string, error) { func (instances *instances) InstanceTypeByProviderID(ctx context.Context, providerID string) (string, error) {
return "", errors.New("Not implemented") return "", errors.New("not implemented")
} }
func (instances *instances) InstanceExistsByProviderID(ctx context.Context, providerID string) (bool, error) { func (instances *instances) InstanceExistsByProviderID(ctx context.Context, providerID string) (bool, error) {
@ -743,7 +743,7 @@ func (instances *instances) InstanceMetadataByProviderID(ctx context.Context, pr
} }
func (instances *instances) List(filter string) ([]types.NodeName, error) { func (instances *instances) List(filter string) ([]types.NodeName, error) {
return []types.NodeName{}, errors.New("Not implemented") return []types.NodeName{}, errors.New("not implemented")
} }
func (instances *instances) AddSSHKeyToAllInstances(ctx context.Context, user string, keyData []byte) error { func (instances *instances) AddSSHKeyToAllInstances(ctx context.Context, user string, keyData []byte) error {
@ -751,5 +751,5 @@ func (instances *instances) AddSSHKeyToAllInstances(ctx context.Context, user st
} }
func (instances *instances) CurrentNodeName(ctx context.Context, hostname string) (types.NodeName, error) { func (instances *instances) CurrentNodeName(ctx context.Context, hostname string) (types.NodeName, error) {
return "", errors.New("Not implemented") return "", errors.New("not implemented")
} }

View File

@ -135,11 +135,11 @@ func (plugin *cinderPlugin) GetVolumeLimits() (map[string]int64, error) {
// default values from here will mean, no one can // default values from here will mean, no one can
// override them. // override them.
if cloud == nil { if cloud == nil {
return nil, fmt.Errorf("No cloudprovider present") return nil, fmt.Errorf("no cloudprovider present")
} }
if cloud.ProviderName() != openstack.ProviderName { if cloud.ProviderName() != openstack.ProviderName {
return nil, fmt.Errorf("Expected Openstack cloud, found %s", cloud.ProviderName()) return nil, fmt.Errorf("expected Openstack cloud, found %s", cloud.ProviderName())
} }
openstackCloud, ok := cloud.(*openstack.OpenStack) openstackCloud, ok := cloud.(*openstack.OpenStack)
@ -477,9 +477,9 @@ func (c *cinderVolumeUnmounter) TearDown() error {
// resource was the last reference to that disk on the kubelet. // resource was the last reference to that disk on the kubelet.
func (c *cinderVolumeUnmounter) TearDownAt(dir string) error { func (c *cinderVolumeUnmounter) TearDownAt(dir string) error {
if pathExists, pathErr := mount.PathExists(dir); pathErr != nil { if pathExists, pathErr := mount.PathExists(dir); pathErr != nil {
return fmt.Errorf("Error checking if path exists: %v", pathErr) return fmt.Errorf("error checking if path exists: %v", pathErr)
} else if !pathExists { } else if !pathExists {
klog.Warningf("Warning: Unmount skipped because path does not exist: %v", dir) klog.Warningf("Warning: Unmount skipped because path does not exist: %w", dir)
return nil return nil
} }

View File

@ -77,7 +77,7 @@ func (util *DiskUtil) AttachDisk(b *cinderVolumeMounter, globalPDPath string) er
} }
numTries++ numTries++
if numTries == 10 { if numTries == 10 {
return errors.New("Could not attach disk: Timeout after 60s") return errors.New("could not attach disk: Timeout after 60s")
} }
time.Sleep(time.Second * 6) time.Sleep(time.Second * 6)
} }

View File

@ -268,7 +268,7 @@ func (b *configMapVolumeMounter) SetUpAt(dir string, mounterArgs volume.MounterA
// MakePayload function is exported so that it can be called from the projection volume driver // MakePayload function is exported so that it can be called from the projection volume driver
func MakePayload(mappings []v1.KeyToPath, configMap *v1.ConfigMap, defaultMode *int32, optional bool) (map[string]volumeutil.FileProjection, error) { func MakePayload(mappings []v1.KeyToPath, configMap *v1.ConfigMap, defaultMode *int32, optional bool) (map[string]volumeutil.FileProjection, error) {
if defaultMode == nil { if defaultMode == nil {
return nil, fmt.Errorf("No defaultMode used, not even the default value for it") return nil, fmt.Errorf("no defaultMode used, not even the default value for it")
} }
payload := make(map[string]volumeutil.FileProjection, (len(configMap.Data) + len(configMap.BinaryData))) payload := make(map[string]volumeutil.FileProjection, (len(configMap.Data) + len(configMap.BinaryData)))

View File

@ -45,7 +45,7 @@ func prepareBlockMapperTest(plug *csiPlugin, specVolumeName string, t *testing.T
volume.VolumeOptions{}, volume.VolumeOptions{},
) )
if err != nil { if err != nil {
return nil, nil, nil, fmt.Errorf("Failed to make a new Mapper: %v", err) return nil, nil, nil, fmt.Errorf("failed to make a new Mapper: %w", err)
} }
csiMapper := mapper.(*csiBlockMapper) csiMapper := mapper.(*csiBlockMapper)
return csiMapper, spec, pv, nil return csiMapper, spec, pv, nil

View File

@ -287,7 +287,7 @@ func initializeCSINode(host volume.VolumeHost) error {
klog.V(4).Infof("Initializing migrated drivers on CSINode") klog.V(4).Infof("Initializing migrated drivers on CSINode")
err := nim.InitializeCSINodeWithAnnotation() err := nim.InitializeCSINodeWithAnnotation()
if err != nil { if err != nil {
kvh.SetKubeletError(fmt.Errorf("Failed to initialize CSINode: %v", err)) kvh.SetKubeletError(fmt.Errorf("failed to initialize CSINode: %v", err))
klog.Errorf("Failed to initialize CSINode: %v", err) klog.Errorf("Failed to initialize CSINode: %v", err)
return false, nil return false, nil
} }

View File

@ -244,7 +244,7 @@ func (b *downwardAPIVolumeMounter) SetUpAt(dir string, mounterArgs volume.Mounte
// Note: this function is exported so that it can be called from the projection volume driver // Note: this function is exported so that it can be called from the projection volume driver
func CollectData(items []v1.DownwardAPIVolumeFile, pod *v1.Pod, host volume.VolumeHost, defaultMode *int32) (map[string]volumeutil.FileProjection, error) { func CollectData(items []v1.DownwardAPIVolumeFile, pod *v1.Pod, host volume.VolumeHost, defaultMode *int32) (map[string]volumeutil.FileProjection, error) {
if defaultMode == nil { if defaultMode == nil {
return nil, fmt.Errorf("No defaultMode used, not even the default value for it") return nil, fmt.Errorf("no defaultMode used, not even the default value for it")
} }
errlist := []error{} errlist := []error{}

View File

@ -489,7 +489,7 @@ func (ed *emptyDir) TearDownAt(dir string) error {
} }
if pathExists, pathErr := mount.PathExists(dir); pathErr != nil { if pathExists, pathErr := mount.PathExists(dir); pathErr != nil {
return fmt.Errorf("Error checking if path exists: %v", pathErr) return fmt.Errorf("error checking if path exists: %w", pathErr)
} else if !pathExists { } else if !pathExists {
klog.Warningf("Warning: Unmount skipped because path does not exist: %v", dir) klog.Warningf("Warning: Unmount skipped because path does not exist: %v", dir)
return nil return nil

View File

@ -271,7 +271,7 @@ func doTestPlugin(t *testing.T, config pluginTestConfig) {
func testSetUp(mounter volume.Mounter, metadataDir, volPath string) error { func testSetUp(mounter volume.Mounter, metadataDir, volPath string) error {
if err := mounter.SetUp(volume.MounterArgs{}); err != nil { if err := mounter.SetUp(volume.MounterArgs{}); err != nil {
return fmt.Errorf("Expected success, got: %v", err) return fmt.Errorf("expected success, got: %w", err)
} }
// Stat the directory and check the permission bits // Stat the directory and check the permission bits
if !volumeutil.IsReady(metadataDir) { if !volumeutil.IsReady(metadataDir) {
@ -285,7 +285,7 @@ func testSetUp(mounter volume.Mounter, metadataDir, volPath string) error {
return fmt.Errorf("SetUp() failed: %v", err) return fmt.Errorf("SetUp() failed: %v", err)
} }
if e, a := perm, fileinfo.Mode().Perm(); e != a { if e, a := perm, fileinfo.Mode().Perm(); e != a {
return fmt.Errorf("Unexpected file mode for %v: expected: %v, got: %v", volPath, e, a) return fmt.Errorf("unexpected file mode for %v: expected: %v, got: %v", volPath, e, a)
} }
return nil return nil
} }

View File

@ -329,7 +329,7 @@ func (util *fcUtil) DetachBlockFCDisk(c fcDiskUnmapper, mapPath, devicePath stri
// Retrieve volume plugin dependent path like '50060e801049cfd1-lun-0' from global map path // Retrieve volume plugin dependent path like '50060e801049cfd1-lun-0' from global map path
arr := strings.Split(mapPath, "/") arr := strings.Split(mapPath, "/")
if len(arr) < 1 { if len(arr) < 1 {
return fmt.Errorf("Fail to retrieve volume plugin information from global map path: %v", mapPath) return fmt.Errorf("failed to retrieve volume plugin information from global map path: %v", mapPath)
} }
volumeInfo := arr[len(arr)-1] volumeInfo := arr[len(arr)-1]
@ -402,7 +402,7 @@ func (util *fcUtil) deleteMultipathDevice(exec utilexec.Interface, dmDevice stri
func checkPathExists(path string) (bool, error) { func checkPathExists(path string) (bool, error) {
if pathExists, pathErr := mount.PathExists(path); pathErr != nil { if pathExists, pathErr := mount.PathExists(path); pathErr != nil {
return pathExists, fmt.Errorf("Error checking if path exists: %v", pathErr) return pathExists, fmt.Errorf("error checking if path exists: %w", pathErr)
} else if !pathExists { } else if !pathExists {
klog.Warningf("Warning: Unmap skipped because path does not exist: %v", path) klog.Warningf("Warning: Unmap skipped because path does not exist: %v", path)
return pathExists, nil return pathExists, nil

View File

@ -58,7 +58,7 @@ func (d *flexVolumeDetacher) UnmountDevice(deviceMountPath string) error {
return nil return nil
} }
if pathErr != nil && !mount.IsCorruptedMnt(pathErr) { if pathErr != nil && !mount.IsCorruptedMnt(pathErr) {
return fmt.Errorf("Error checking path: %v", pathErr) return fmt.Errorf("error checking path: %w", pathErr)
} }
notmnt, err := isNotMounted(d.plugin.host.GetMounter(d.plugin.GetPluginName()), deviceMountPath) notmnt, err := isNotMounted(d.plugin.host.GetMounter(d.plugin.GetPluginName()), deviceMountPath)
@ -87,7 +87,7 @@ func (d *flexVolumeDetacher) UnmountDevice(deviceMountPath string) error {
// Flexvolume driver may remove the directory. Ignore if it does. // Flexvolume driver may remove the directory. Ignore if it does.
if pathExists, pathErr := mount.PathExists(deviceMountPath); pathErr != nil { if pathExists, pathErr := mount.PathExists(deviceMountPath); pathErr != nil {
return fmt.Errorf("Error checking if path exists: %v", pathErr) return fmt.Errorf("error checking if path exists: %w", pathErr)
} else if !pathExists { } else if !pathExists {
return nil return nil
} }

View File

@ -69,7 +69,7 @@ const (
) )
var ( var (
errTimeout = fmt.Errorf("Timeout") errTimeout = fmt.Errorf("timeout")
) )
// DriverCall implements the basic contract between FlexVolume and its driver. // DriverCall implements the basic contract between FlexVolume and its driver.
@ -108,7 +108,7 @@ func (dc *DriverCall) AppendSpec(spec *volume.Spec, host volume.VolumeHost, extr
jsonBytes, err := json.Marshal(optionsForDriver) jsonBytes, err := json.Marshal(optionsForDriver)
if err != nil { if err != nil {
return fmt.Errorf("Failed to marshal spec, error: %s", err.Error()) return fmt.Errorf("failed to marshal spec, error: %s", err.Error())
} }
dc.Append(string(jsonBytes)) dc.Append(string(jsonBytes))

View File

@ -104,7 +104,7 @@ func (prober *flexVolumeProber) probeAll() (events []volume.ProbeEvent, err erro
allErrs := []error{} allErrs := []error{}
files, err := prober.fs.ReadDir(prober.pluginDir) files, err := prober.fs.ReadDir(prober.pluginDir)
if err != nil { if err != nil {
return nil, fmt.Errorf("Error reading the Flexvolume directory: %s", err) return nil, fmt.Errorf("error reading the Flexvolume directory: %s", err)
} }
for _, f := range files { for _, f := range files {
// only directories with names that do not begin with '.' are counted as plugins // only directories with names that do not begin with '.' are counted as plugins
@ -132,7 +132,7 @@ func (prober *flexVolumeProber) newProbeEvent(driverDirName string, op volume.Pr
plugin, pluginErr := prober.factory.NewFlexVolumePlugin(prober.pluginDir, driverDirName, prober.runner) plugin, pluginErr := prober.factory.NewFlexVolumePlugin(prober.pluginDir, driverDirName, prober.runner)
if pluginErr != nil { if pluginErr != nil {
pluginErr = fmt.Errorf( pluginErr = fmt.Errorf(
"Error creating Flexvolume plugin from directory %s, skipping. Error: %s", "error creating Flexvolume plugin from directory %s, skipping. Error: %s",
driverDirName, pluginErr) driverDirName, pluginErr)
return probeEvent, pluginErr return probeEvent, pluginErr
} }
@ -250,11 +250,11 @@ func (prober *flexVolumeProber) initWatcher() error {
klog.Errorf("Received an error from watcher: %s", err) klog.Errorf("Received an error from watcher: %s", err)
}) })
if err != nil { if err != nil {
return fmt.Errorf("Error initializing watcher: %s", err) return fmt.Errorf("error initializing watcher: %s", err)
} }
if err := prober.addWatchRecursive(prober.pluginDir); err != nil { if err := prober.addWatchRecursive(prober.pluginDir); err != nil {
return fmt.Errorf("Error adding watch on Flexvolume directory: %s", err) return fmt.Errorf("error adding watch on Flexvolume directory: %s", err)
} }
prober.watcher.Run() prober.watcher.Run()
@ -268,7 +268,7 @@ func (prober *flexVolumeProber) createPluginDir() error {
klog.Warningf("Flexvolume plugin directory at %s does not exist. Recreating.", prober.pluginDir) klog.Warningf("Flexvolume plugin directory at %s does not exist. Recreating.", prober.pluginDir)
err := prober.fs.MkdirAll(prober.pluginDir, 0755) err := prober.fs.MkdirAll(prober.pluginDir, 0755)
if err != nil { if err != nil {
return fmt.Errorf("Error (re-)creating driver directory: %s", err) return fmt.Errorf("error (re-)creating driver directory: %s", err)
} }
} }

View File

@ -66,7 +66,7 @@ func (f *flexVolumeUnmounter) TearDownAt(dir string) error {
// Flexvolume driver may remove the directory. Ignore if it does. // Flexvolume driver may remove the directory. Ignore if it does.
if pathExists, pathErr := mount.PathExists(dir); pathErr != nil { if pathExists, pathErr := mount.PathExists(dir); pathErr != nil {
return fmt.Errorf("Error checking if path exists: %v", pathErr) return fmt.Errorf("error checking if path exists: %w", pathErr)
} else if !pathExists { } else if !pathExists {
return nil return nil
} }

View File

@ -40,12 +40,12 @@ func addSecretsToOptions(options map[string]string, spec *volume.Spec, namespace
kubeClient := host.GetKubeClient() kubeClient := host.GetKubeClient()
if kubeClient == nil { if kubeClient == nil {
return fmt.Errorf("Cannot get kube client") return fmt.Errorf("cannot get kube client")
} }
secrets, err := util.GetSecretForPV(secretNamespace, secretName, driverName, host.GetKubeClient()) secrets, err := util.GetSecretForPV(secretNamespace, secretName, driverName, host.GetKubeClient())
if err != nil { if err != nil {
err = fmt.Errorf("Couldn't get secret %v/%v err: %v", secretNamespace, secretName, err) err = fmt.Errorf("couldn't get secret %v/%v err: %w", secretNamespace, secretName, err)
return err return err
} }
for name, data := range secrets { for name, data := range secrets {

View File

@ -200,7 +200,7 @@ func (b *flockerVolume) GetDatasetUUID() (datasetUUID string, err error) {
} }
if b.flockerClient == nil { if b.flockerClient == nil {
return "", fmt.Errorf("Flocker client is not initialized") return "", fmt.Errorf("flocker client is not initialized")
} }
// lookup in flocker API otherwise // lookup in flocker API otherwise
@ -285,12 +285,12 @@ func (b *flockerVolumeMounter) SetUpAt(dir string, mounterArgs volume.MounterArg
datasetUUID, err := b.GetDatasetUUID() datasetUUID, err := b.GetDatasetUUID()
if err != nil { if err != nil {
return fmt.Errorf("The datasetUUID for volume with datasetName='%s' can not be found using flocker: %s", b.datasetName, err) return fmt.Errorf("the datasetUUID for volume with datasetName='%s' can not be found using flocker: %s", b.datasetName, err)
} }
datasetState, err := b.flockerClient.GetDatasetState(datasetUUID) datasetState, err := b.flockerClient.GetDatasetState(datasetUUID)
if err != nil { if err != nil {
return fmt.Errorf("The datasetState for volume with datasetUUID='%s' could not determinted uusing flocker: %s", datasetUUID, err) return fmt.Errorf("the datasetState for volume with datasetUUID='%s' could not determinted uusing flocker: %s", datasetUUID, err)
} }
primaryUUID, err := b.flockerClient.GetPrimaryUUID() primaryUUID, err := b.flockerClient.GetPrimaryUUID()
@ -304,7 +304,7 @@ func (b *flockerVolumeMounter) SetUpAt(dir string, mounterArgs volume.MounterArg
} }
_, err := b.flockerClient.GetDatasetState(datasetUUID) _, err := b.flockerClient.GetDatasetState(datasetUUID)
if err != nil { if err != nil {
return fmt.Errorf("The volume with datasetUUID='%s' migrated unsuccessfully", datasetUUID) return fmt.Errorf("the volume with datasetUUID='%s' migrated unsuccessfully", datasetUUID)
} }
} }

View File

@ -92,7 +92,7 @@ func (c *fakeFlockerClient) GetDatasetID(metaName string) (datasetID string, err
if val, ok := c.Metadata["Name"]; !ok { if val, ok := c.Metadata["Name"]; !ok {
return val, nil return val, nil
} }
return "", fmt.Errorf("No dataset with metadata X found") return "", fmt.Errorf("no dataset with metadata X found")
} }
func (c *fakeFlockerClient) GetPrimaryUUID() (primaryUUID string, err error) { func (c *fakeFlockerClient) GetPrimaryUUID() (primaryUUID string, err error) {

View File

@ -52,7 +52,7 @@ func TestFlockerUtil_CreateVolume(t *testing.T) {
assert.Equal(3, size) assert.Equal(3, size)
// test error during CreateVolume // test error during CreateVolume
fakeFlockerClient.Error = fmt.Errorf("Do not feel like provisioning") fakeFlockerClient.Error = fmt.Errorf("do not feel like provisioning")
_, _, _, err = flockerUtil.CreateVolume(provisioner) _, _, _, err = flockerUtil.CreateVolume(provisioner)
assert.Equal(fakeFlockerClient.Error.Error(), err.Error()) assert.Equal(fakeFlockerClient.Error.Error(), err.Error())
} }

View File

@ -60,11 +60,11 @@ func (c *flockerVolumeProvisioner) Provision(selectedNode *v1.Node, allowedTopol
} }
if len(c.options.Parameters) > 0 { if len(c.options.Parameters) > 0 {
return nil, fmt.Errorf("Provisioning failed: Specified at least one unsupported parameter") return nil, fmt.Errorf("provisioning failed: Specified at least one unsupported parameter")
} }
if c.options.PVC.Spec.Selector != nil { if c.options.PVC.Spec.Selector != nil {
return nil, fmt.Errorf("Provisioning failed: Specified unsupported selector") return nil, fmt.Errorf("provisioning failed: Specified unsupported selector")
} }
if util.CheckPersistentVolumeClaimModeBlock(c.options.PVC) { if util.CheckPersistentVolumeClaimModeBlock(c.options.PVC) {

View File

@ -114,9 +114,9 @@ func TestAttachDetach(t *testing.T) {
readOnly := false readOnly := false
regional := false regional := false
spec := createVolSpec(diskName, readOnly) spec := createVolSpec(diskName, readOnly)
attachError := errors.New("Fake attach error") attachError := errors.New("fake attach error")
detachError := errors.New("Fake detach error") detachError := errors.New("fake detach error")
diskCheckError := errors.New("Fake DiskIsAttached error") diskCheckError := errors.New("fake DiskIsAttached error")
tests := []testcase{ tests := []testcase{
// Successful Attach call // Successful Attach call
{ {
@ -498,19 +498,19 @@ func (testcase *testcase) AttachDisk(diskName string, nodeName types.NodeName, r
} }
if expected.diskName != diskName { if expected.diskName != diskName {
return fmt.Errorf("Unexpected AttachDisk call: expected diskName %s, got %s", expected.diskName, diskName) return fmt.Errorf("unexpected AttachDisk call: expected diskName %s, got %s", expected.diskName, diskName)
} }
if expected.nodeName != nodeName { if expected.nodeName != nodeName {
return fmt.Errorf("Unexpected AttachDisk call: expected nodeName %s, got %s", expected.nodeName, nodeName) return fmt.Errorf("unexpected AttachDisk call: expected nodeName %s, got %s", expected.nodeName, nodeName)
} }
if expected.readOnly != readOnly { if expected.readOnly != readOnly {
return fmt.Errorf("Unexpected AttachDisk call: expected readOnly %v, got %v", expected.readOnly, readOnly) return fmt.Errorf("unexpected AttachDisk call: expected readOnly %v, got %v", expected.readOnly, readOnly)
} }
if expected.regional != regional { if expected.regional != regional {
return fmt.Errorf("Unexpected AttachDisk call: expected regional %v, got %v", expected.regional, regional) return fmt.Errorf("unexpected AttachDisk call: expected regional %v, got %v", expected.regional, regional)
} }
klog.V(4).Infof("AttachDisk call: %s, %s, %v, returning %v", diskName, nodeName, readOnly, expected.retErr) klog.V(4).Infof("AttachDisk call: %s, %s, %v, returning %v", diskName, nodeName, readOnly, expected.retErr)
@ -527,11 +527,11 @@ func (testcase *testcase) DetachDisk(devicePath string, nodeName types.NodeName)
} }
if expected.devicePath != devicePath { if expected.devicePath != devicePath {
return fmt.Errorf("Unexpected DetachDisk call: expected devicePath %s, got %s", expected.devicePath, devicePath) return fmt.Errorf("unexpected DetachDisk call: expected devicePath %s, got %s", expected.devicePath, devicePath)
} }
if expected.nodeName != nodeName { if expected.nodeName != nodeName {
return fmt.Errorf("Unexpected DetachDisk call: expected nodeName %s, got %s", expected.nodeName, nodeName) return fmt.Errorf("unexpected DetachDisk call: expected nodeName %s, got %s", expected.nodeName, nodeName)
} }
klog.V(4).Infof("DetachDisk call: %s, %s, returning %v", devicePath, nodeName, expected.retErr) klog.V(4).Infof("DetachDisk call: %s, %s, returning %v", devicePath, nodeName, expected.retErr)
@ -598,24 +598,24 @@ func (testcase *testcase) BulkDisksAreAttached(diskByNodes map[types.NodeName][]
} }
func (testcase *testcase) CreateDisk(name string, diskType string, zone string, sizeGb int64, tags map[string]string) (*gce.Disk, error) { func (testcase *testcase) CreateDisk(name string, diskType string, zone string, sizeGb int64, tags map[string]string) (*gce.Disk, error) {
return nil, errors.New("Not implemented") return nil, errors.New("not implemented")
} }
func (testcase *testcase) CreateRegionalDisk(name string, diskType string, replicaZones sets.String, sizeGb int64, tags map[string]string) (*gce.Disk, error) { func (testcase *testcase) CreateRegionalDisk(name string, diskType string, replicaZones sets.String, sizeGb int64, tags map[string]string) (*gce.Disk, error) {
return nil, errors.New("Not implemented") return nil, errors.New("not implemented")
} }
func (testcase *testcase) DeleteDisk(diskToDelete string) error { func (testcase *testcase) DeleteDisk(diskToDelete string) error {
return errors.New("Not implemented") return errors.New("not implemented")
} }
func (testcase *testcase) GetAutoLabelsForPD(*gce.Disk) (map[string]string, error) { func (testcase *testcase) GetAutoLabelsForPD(*gce.Disk) (map[string]string, error) {
return map[string]string{}, errors.New("Not implemented") return map[string]string{}, errors.New("not implemented")
} }
func (testcase *testcase) ResizeDisk( func (testcase *testcase) ResizeDisk(
diskName string, diskName string,
oldSize resource.Quantity, oldSize resource.Quantity,
newSize resource.Quantity) (resource.Quantity, error) { newSize resource.Quantity) (resource.Quantity, error) {
return oldSize, errors.New("Not implemented") return oldSize, errors.New("not implemented")
} }

View File

@ -296,7 +296,7 @@ func doTestPlugin(scenario struct {
plug, err := plugMgr.FindPluginByName("kubernetes.io/git-repo") plug, err := plugMgr.FindPluginByName("kubernetes.io/git-repo")
if err != nil { if err != nil {
allErrs = append(allErrs, allErrs = append(allErrs,
fmt.Errorf("Can't find the plugin by name")) fmt.Errorf("can't find the plugin by name"))
return allErrs return allErrs
} }
pod := &v1.Pod{ObjectMeta: metav1.ObjectMeta{UID: types.UID("poduid")}} pod := &v1.Pod{ObjectMeta: metav1.ObjectMeta{UID: types.UID("poduid")}}
@ -304,12 +304,12 @@ func doTestPlugin(scenario struct {
if err != nil { if err != nil {
allErrs = append(allErrs, allErrs = append(allErrs,
fmt.Errorf("Failed to make a new Mounter: %v", err)) fmt.Errorf("failed to make a new Mounter: %w", err))
return allErrs return allErrs
} }
if mounter == nil { if mounter == nil {
allErrs = append(allErrs, allErrs = append(allErrs,
fmt.Errorf("Got a nil Mounter")) fmt.Errorf("got a nil Mounter"))
return allErrs return allErrs
} }
@ -317,7 +317,7 @@ func doTestPlugin(scenario struct {
suffix := fmt.Sprintf("pods/poduid/volumes/kubernetes.io~git-repo/%v", scenario.vol.Name) suffix := fmt.Sprintf("pods/poduid/volumes/kubernetes.io~git-repo/%v", scenario.vol.Name)
if !strings.HasSuffix(path, suffix) { if !strings.HasSuffix(path, suffix) {
allErrs = append(allErrs, allErrs = append(allErrs,
fmt.Errorf("Got unexpected path: %s", path)) fmt.Errorf("got unexpected path: %s", path))
return allErrs return allErrs
} }
@ -353,18 +353,18 @@ func doTestPlugin(scenario struct {
unmounter, err := plug.NewUnmounter("vol1", types.UID("poduid")) unmounter, err := plug.NewUnmounter("vol1", types.UID("poduid"))
if err != nil { if err != nil {
allErrs = append(allErrs, allErrs = append(allErrs,
fmt.Errorf("Failed to make a new Unmounter: %v", err)) fmt.Errorf("failed to make a new Unmounter: %w", err))
return allErrs return allErrs
} }
if unmounter == nil { if unmounter == nil {
allErrs = append(allErrs, allErrs = append(allErrs,
fmt.Errorf("Got a nil Unmounter")) fmt.Errorf("got a nil Unmounter"))
return allErrs return allErrs
} }
if err := unmounter.TearDown(); err != nil { if err := unmounter.TearDown(); err != nil {
allErrs = append(allErrs, allErrs = append(allErrs,
fmt.Errorf("Expected success, got: %v", err)) fmt.Errorf("expected success, got: %w", err))
return allErrs return allErrs
} }
if _, err := os.Stat(path); err == nil { if _, err := os.Stat(path); err == nil {
@ -372,7 +372,7 @@ func doTestPlugin(scenario struct {
fmt.Errorf("TearDown() failed, volume path still exists: %s", path)) fmt.Errorf("TearDown() failed, volume path still exists: %s", path))
} else if !os.IsNotExist(err) { } else if !os.IsNotExist(err) {
allErrs = append(allErrs, allErrs = append(allErrs,
fmt.Errorf("TearDown() failed: %v", err)) fmt.Errorf("TearDown() failed: %w", err))
} }
return allErrs return allErrs
} }

View File

@ -743,7 +743,7 @@ func TestParseClassParameters(t *testing.T) {
if test.secret != nil { if test.secret != nil {
return true, test.secret, nil return true, test.secret, nil
} }
return true, nil, fmt.Errorf("Test %s did not set a secret", test.name) return true, nil, fmt.Errorf("test %s did not set a secret", test.name)
}) })
cfg, err := parseClassParameters(test.parameters, client) cfg, err := parseClassParameters(test.parameters, client)

View File

@ -589,11 +589,11 @@ func createSecretMap(spec *volume.Spec, plugin *iscsiPlugin, namespace string) (
// if secret is provideded, retrieve it // if secret is provideded, retrieve it
kubeClient := plugin.host.GetKubeClient() kubeClient := plugin.host.GetKubeClient()
if kubeClient == nil { if kubeClient == nil {
return nil, fmt.Errorf("Cannot get kube client") return nil, fmt.Errorf("cannot get kube client")
} }
secretObj, err := kubeClient.CoreV1().Secrets(secretNamespace).Get(context.TODO(), secretName, metav1.GetOptions{}) secretObj, err := kubeClient.CoreV1().Secrets(secretNamespace).Get(context.TODO(), secretName, metav1.GetOptions{})
if err != nil { if err != nil {
err = fmt.Errorf("Couldn't get secret %v/%v error: %v", secretNamespace, secretName, err) err = fmt.Errorf("couldn't get secret %v/%v error: %w", secretNamespace, secretName, err)
return nil, err return nil, err
} }
secret = make(map[string]string) secret = make(map[string]string)

View File

@ -253,7 +253,7 @@ func scanOneLun(hostNumber int, lunNumber int) error {
if written, err := fd.WriteString(scanCmd); err != nil { if written, err := fd.WriteString(scanCmd); err != nil {
return err return err
} else if 0 == written { } else if 0 == written {
return fmt.Errorf("No data written to file: %s", filename) return fmt.Errorf("no data written to file: %s", filename)
} }
klog.V(3).Infof("Scanned SCSI host %d LUN %d", hostNumber, lunNumber) klog.V(3).Infof("Scanned SCSI host %d LUN %d", hostNumber, lunNumber)
@ -404,7 +404,7 @@ func (util *ISCSIUtil) AttachDisk(b iscsiDiskMounter) (string, error) {
if iscsiTransport == "" { if iscsiTransport == "" {
klog.Errorf("iscsi: could not find transport name in iface %s", b.Iface) klog.Errorf("iscsi: could not find transport name in iface %s", b.Iface)
return "", fmt.Errorf("Could not parse iface file for %s", b.Iface) return "", fmt.Errorf("could not parse iface file for %s", b.Iface)
} }
if iscsiTransport == "tcp" { if iscsiTransport == "tcp" {
devicePath = strings.Join([]string{"/dev/disk/by-path/ip", tp, "iscsi", b.Iqn, "lun", b.Lun}, "-") devicePath = strings.Join([]string{"/dev/disk/by-path/ip", tp, "iscsi", b.Iqn, "lun", b.Lun}, "-")
@ -524,7 +524,7 @@ func deleteDevice(deviceName string) error {
if written, err := fd.WriteString("1"); err != nil { if written, err := fd.WriteString("1"); err != nil {
return err return err
} else if 0 == written { } else if 0 == written {
return fmt.Errorf("No data written to file: %s", filename) return fmt.Errorf("no data written to file: %s", filename)
} }
klog.V(4).Infof("Deleted block device: %s", deviceName) klog.V(4).Infof("Deleted block device: %s", deviceName)
return nil return nil
@ -576,7 +576,7 @@ func deleteDevices(c iscsiDiskUnmounter) error {
// DetachDisk unmounts and detaches a volume from node // DetachDisk unmounts and detaches a volume from node
func (util *ISCSIUtil) DetachDisk(c iscsiDiskUnmounter, mntPath string) error { func (util *ISCSIUtil) DetachDisk(c iscsiDiskUnmounter, mntPath string) error {
if pathExists, pathErr := mount.PathExists(mntPath); pathErr != nil { if pathExists, pathErr := mount.PathExists(mntPath); pathErr != nil {
return fmt.Errorf("Error checking if path exists: %v", pathErr) return fmt.Errorf("error checking if path exists: %w", pathErr)
} else if !pathExists { } else if !pathExists {
klog.Warningf("Warning: Unmount skipped because path does not exist: %v", mntPath) klog.Warningf("Warning: Unmount skipped because path does not exist: %v", mntPath)
return nil return nil
@ -652,7 +652,7 @@ func (util *ISCSIUtil) DetachDisk(c iscsiDiskUnmounter, mntPath string) error {
// DetachBlockISCSIDisk removes loopback device for a volume and detaches a volume from node // DetachBlockISCSIDisk removes loopback device for a volume and detaches a volume from node
func (util *ISCSIUtil) DetachBlockISCSIDisk(c iscsiDiskUnmapper, mapPath string) error { func (util *ISCSIUtil) DetachBlockISCSIDisk(c iscsiDiskUnmapper, mapPath string) error {
if pathExists, pathErr := mount.PathExists(mapPath); pathErr != nil { if pathExists, pathErr := mount.PathExists(mapPath); pathErr != nil {
return fmt.Errorf("Error checking if path exists: %v", pathErr) return fmt.Errorf("error checking if path exists: %w", pathErr)
} else if !pathExists { } else if !pathExists {
klog.Warningf("Warning: Unmap skipped because path does not exist: %v", mapPath) klog.Warningf("Warning: Unmap skipped because path does not exist: %v", mapPath)
return nil return nil
@ -838,7 +838,7 @@ func parseIscsiadmShow(output string) (map[string]string, error) {
} }
iface := strings.Fields(line) iface := strings.Fields(line)
if len(iface) != 3 || iface[1] != "=" { if len(iface) != 3 || iface[1] != "=" {
return nil, fmt.Errorf("Error: invalid iface setting: %v", iface) return nil, fmt.Errorf("error: invalid iface setting: %v", iface)
} }
// iscsi_ifacename is immutable once the iface is created // iscsi_ifacename is immutable once the iface is created
if iface[0] == "iface.iscsi_ifacename" { if iface[0] == "iface.iscsi_ifacename" {

View File

@ -418,13 +418,13 @@ func testFSGroupMount(plug volume.VolumePlugin, pod *v1.Pod, tmpDir string, fsGr
return err return err
} }
if mounter == nil { if mounter == nil {
return fmt.Errorf("Got a nil Mounter") return fmt.Errorf("got a nil Mounter")
} }
volPath := filepath.Join(tmpDir, testMountPath) volPath := filepath.Join(tmpDir, testMountPath)
path := mounter.GetPath() path := mounter.GetPath()
if path != volPath { if path != volPath {
return fmt.Errorf("Got unexpected path: %s", path) return fmt.Errorf("got unexpected path: %s", path)
} }
var mounterArgs volume.MounterArgs var mounterArgs volume.MounterArgs

View File

@ -206,15 +206,15 @@ func (nfsMounter *nfsMounter) CanMount() error {
switch runtime.GOOS { switch runtime.GOOS {
case "linux": case "linux":
if _, err := exec.Command("test", "-x", "/sbin/mount.nfs").CombinedOutput(); err != nil { if _, err := exec.Command("test", "-x", "/sbin/mount.nfs").CombinedOutput(); err != nil {
return fmt.Errorf("Required binary /sbin/mount.nfs is missing") return fmt.Errorf("required binary /sbin/mount.nfs is missing")
} }
if _, err := exec.Command("test", "-x", "/sbin/mount.nfs4").CombinedOutput(); err != nil { if _, err := exec.Command("test", "-x", "/sbin/mount.nfs4").CombinedOutput(); err != nil {
return fmt.Errorf("Required binary /sbin/mount.nfs4 is missing") return fmt.Errorf("required binary /sbin/mount.nfs4 is missing")
} }
return nil return nil
case "darwin": case "darwin":
if _, err := exec.Command("test", "-x", "/sbin/mount_nfs").CombinedOutput(); err != nil { if _, err := exec.Command("test", "-x", "/sbin/mount_nfs").CombinedOutput(); err != nil {
return fmt.Errorf("Required binary /sbin/mount_nfs is missing") return fmt.Errorf("required binary /sbin/mount_nfs is missing")
} }
} }
return nil return nil

View File

@ -649,7 +649,7 @@ func (pm *VolumePluginMgr) initProbedPlugin(probedPlugin VolumePlugin) error {
err := probedPlugin.Init(pm.Host) err := probedPlugin.Init(pm.Host)
if err != nil { if err != nil {
return fmt.Errorf("Failed to load volume plugin %s, error: %s", name, err.Error()) return fmt.Errorf("failed to load volume plugin %s, error: %s", name, err.Error())
} }
klog.V(1).Infof("Loaded volume plugin %q", name) klog.V(1).Infof("Loaded volume plugin %q", name)
@ -664,7 +664,7 @@ func (pm *VolumePluginMgr) FindPluginBySpec(spec *Spec) (VolumePlugin, error) {
defer pm.mutex.RUnlock() defer pm.mutex.RUnlock()
if spec == nil { if spec == nil {
return nil, fmt.Errorf("Could not find plugin because volume spec is nil") return nil, fmt.Errorf("could not find plugin because volume spec is nil")
} }
matches := []VolumePlugin{} matches := []VolumePlugin{}
@ -787,7 +787,7 @@ func (pm *VolumePluginMgr) ListVolumePluginWithLimits() []VolumePluginWithAttach
func (pm *VolumePluginMgr) FindPersistentPluginBySpec(spec *Spec) (PersistentVolumePlugin, error) { func (pm *VolumePluginMgr) FindPersistentPluginBySpec(spec *Spec) (PersistentVolumePlugin, error) {
volumePlugin, err := pm.FindPluginBySpec(spec) volumePlugin, err := pm.FindPluginBySpec(spec)
if err != nil { if err != nil {
return nil, fmt.Errorf("Could not find volume plugin for spec: %#v", spec) return nil, fmt.Errorf("could not find volume plugin for spec: %#v", spec)
} }
if persistentVolumePlugin, ok := volumePlugin.(PersistentVolumePlugin); ok { if persistentVolumePlugin, ok := volumePlugin.(PersistentVolumePlugin); ok {
return persistentVolumePlugin, nil return persistentVolumePlugin, nil
@ -800,7 +800,7 @@ func (pm *VolumePluginMgr) FindPersistentPluginBySpec(spec *Spec) (PersistentVol
func (pm *VolumePluginMgr) FindVolumePluginWithLimitsBySpec(spec *Spec) (VolumePluginWithAttachLimits, error) { func (pm *VolumePluginMgr) FindVolumePluginWithLimitsBySpec(spec *Spec) (VolumePluginWithAttachLimits, error) {
volumePlugin, err := pm.FindPluginBySpec(spec) volumePlugin, err := pm.FindPluginBySpec(spec)
if err != nil { if err != nil {
return nil, fmt.Errorf("Could not find volume plugin for spec : %#v", spec) return nil, fmt.Errorf("could not find volume plugin for spec : %#v", spec)
} }
if limitedPlugin, ok := volumePlugin.(VolumePluginWithAttachLimits); ok { if limitedPlugin, ok := volumePlugin.(VolumePluginWithAttachLimits); ok {

View File

@ -360,7 +360,7 @@ func lookupPXAPIPortFromService(svc *v1.Service) int32 {
func getPortworxService(host volume.VolumeHost) (*v1.Service, error) { func getPortworxService(host volume.VolumeHost) (*v1.Service, error) {
kubeClient := host.GetKubeClient() kubeClient := host.GetKubeClient()
if kubeClient == nil { if kubeClient == nil {
err := fmt.Errorf("Failed to get kubeclient when creating portworx client") err := fmt.Errorf("failed to get kubeclient when creating portworx client")
klog.Errorf(err.Error()) klog.Errorf(err.Error())
return nil, err return nil, err
} }
@ -373,7 +373,7 @@ func getPortworxService(host volume.VolumeHost) (*v1.Service, error) {
} }
if svc == nil { if svc == nil {
err = fmt.Errorf("Service: %v not found. Consult Portworx docs to deploy it", pxServiceName) err = fmt.Errorf("service: %v not found. Consult Portworx docs to deploy it", pxServiceName)
klog.Errorf(err.Error()) klog.Errorf(err.Error())
return nil, err return nil, err
} }

View File

@ -248,12 +248,12 @@ func (s *projectedVolumeMounter) SetUpAt(dir string, mounterArgs volume.MounterA
func (s *projectedVolumeMounter) collectData(mounterArgs volume.MounterArgs) (map[string]volumeutil.FileProjection, error) { func (s *projectedVolumeMounter) collectData(mounterArgs volume.MounterArgs) (map[string]volumeutil.FileProjection, error) {
if s.source.DefaultMode == nil { if s.source.DefaultMode == nil {
return nil, fmt.Errorf("No defaultMode used, not even the default value for it") return nil, fmt.Errorf("no defaultMode used, not even the default value for it")
} }
kubeClient := s.plugin.host.GetKubeClient() kubeClient := s.plugin.host.GetKubeClient()
if kubeClient == nil { if kubeClient == nil {
return nil, fmt.Errorf("Cannot setup projected volume %v because kube client is not configured", s.volName) return nil, fmt.Errorf("cannot setup projected volume %v because kube client is not configured", s.volName)
} }
errlist := []error{} errlist := []error{}

View File

@ -777,7 +777,7 @@ func TestCollectDataWithServiceAccountToken(t *testing.T) {
{ {
name: "no default mode", name: "no default mode",
path: "token", path: "token",
wantErr: fmt.Errorf("No defaultMode used, not even the default value for it"), wantErr: fmt.Errorf("no defaultMode used, not even the default value for it"),
}, },
{ {
name: "fsUser != nil", name: "fsUser != nil",

View File

@ -416,7 +416,7 @@ func (provisioner *quobyteVolumeProvisioner) Provision(selectedNode *v1.Node, al
} }
if !validateRegistry(provisioner.registry) { if !validateRegistry(provisioner.registry) {
return nil, fmt.Errorf("Quobyte registry missing or malformed: must be a host:port pair or multiple pairs separated by commas") return nil, fmt.Errorf("quobyte registry missing or malformed: must be a host:port pair or multiple pairs separated by commas")
} }
// create random image name // create random image name
@ -493,7 +493,7 @@ func parseAPIConfig(plugin *quobytePlugin, params map[string]string) (*quobyteAP
} }
if len(apiServer) == 0 { if len(apiServer) == 0 {
return nil, fmt.Errorf("Quobyte API server missing or malformed: must be a http(s)://host:port pair or multiple pairs separated by commas") return nil, fmt.Errorf("quobyte API server missing or malformed: must be a http(s)://host:port pair or multiple pairs separated by commas")
} }
secretMap, err := util.GetSecretForPV(secretNamespace, secretName, quobytePluginName, plugin.host.GetKubeClient()) secretMap, err := util.GetSecretForPV(secretNamespace, secretName, quobytePluginName, plugin.host.GetKubeClient())
@ -507,11 +507,11 @@ func parseAPIConfig(plugin *quobytePlugin, params map[string]string) (*quobyteAP
var ok bool var ok bool
if cfg.quobyteUser, ok = secretMap["user"]; !ok { if cfg.quobyteUser, ok = secretMap["user"]; !ok {
return nil, fmt.Errorf("Missing \"user\" in secret %s/%s", secretNamespace, secretName) return nil, fmt.Errorf("missing \"user\" in secret %s/%s", secretNamespace, secretName)
} }
if cfg.quobytePassword, ok = secretMap["password"]; !ok { if cfg.quobytePassword, ok = secretMap["password"]; !ok {
return nil, fmt.Errorf("Missing \"password\" in secret %s/%s", secretNamespace, secretName) return nil, fmt.Errorf("missing \"password\" in secret %s/%s", secretNamespace, secretName)
} }
return cfg, nil return cfg, nil

View File

@ -263,7 +263,7 @@ func (b *secretVolumeMounter) SetUpAt(dir string, mounterArgs volume.MounterArgs
// MakePayload function is exported so that it can be called from the projection volume driver // MakePayload function is exported so that it can be called from the projection volume driver
func MakePayload(mappings []v1.KeyToPath, secret *v1.Secret, defaultMode *int32, optional bool) (map[string]volumeutil.FileProjection, error) { func MakePayload(mappings []v1.KeyToPath, secret *v1.Secret, defaultMode *int32, optional bool) (map[string]volumeutil.FileProjection, error) {
if defaultMode == nil { if defaultMode == nil {
return nil, fmt.Errorf("No defaultMode used, not even the default value for it") return nil, fmt.Errorf("no defaultMode used, not even the default value for it")
} }
payload := make(map[string]volumeutil.FileProjection, len(secret.Data)) payload := make(map[string]volumeutil.FileProjection, len(secret.Data))

View File

@ -452,7 +452,7 @@ func getVolumeInfo(pvName string, podUID types.UID, host volume.VolumeHost) (str
volumeDir := filepath.Dir(host.GetPodVolumeDir(podUID, utilstrings.EscapeQualifiedName(storageosPluginName), pvName)) volumeDir := filepath.Dir(host.GetPodVolumeDir(podUID, utilstrings.EscapeQualifiedName(storageosPluginName), pvName))
files, err := ioutil.ReadDir(volumeDir) files, err := ioutil.ReadDir(volumeDir)
if err != nil { if err != nil {
return "", "", fmt.Errorf("Could not read mounts from pod volume dir: %s", err) return "", "", fmt.Errorf("could not read mounts from pod volume dir: %s", err)
} }
for _, f := range files { for _, f := range files {
if f.Mode().IsDir() && strings.HasPrefix(f.Name(), pvName+".") { if f.Mode().IsDir() && strings.HasPrefix(f.Name(), pvName+".") {
@ -461,7 +461,7 @@ func getVolumeInfo(pvName string, podUID types.UID, host volume.VolumeHost) (str
} }
} }
} }
return "", "", fmt.Errorf("Could not get info from unmounted pv %q at %q", pvName, volumeDir) return "", "", fmt.Errorf("could not get info from unmounted pv %q at %q", pvName, volumeDir)
} }
// Splits the volume ref on "." to return the volNamespace and pvName. Neither // Splits the volume ref on "." to return the volNamespace and pvName. Neither

View File

@ -959,7 +959,7 @@ func (fv *FakeVolume) Attach(spec *Spec, nodeName types.NodeName) (string, error
// even if volume was previously attached to time out, we need to keep returning error // even if volume was previously attached to time out, we need to keep returning error
// so as reconciler can not confirm this volume as attached. // so as reconciler can not confirm this volume as attached.
if nodeName == TimeoutAttachNode { if nodeName == TimeoutAttachNode {
return "", fmt.Errorf("Timed out to attach volume %q to node %q", volumeName, nodeName) return "", fmt.Errorf("timed out to attach volume %q to node %q", volumeName, nodeName)
} }
if volumeNodes.Has(string(nodeName)) || volumeNodes.Has(MultiAttachNode) || nodeName == MultiAttachNode { if volumeNodes.Has(string(nodeName)) || volumeNodes.Has(MultiAttachNode) || nodeName == MultiAttachNode {
volumeNodes.Insert(string(nodeName)) volumeNodes.Insert(string(nodeName))
@ -970,7 +970,7 @@ func (fv *FakeVolume) Attach(spec *Spec, nodeName types.NodeName) (string, error
fv.VolumesAttached[volumeName] = sets.NewString(string(nodeName)) fv.VolumesAttached[volumeName] = sets.NewString(string(nodeName))
if nodeName == UncertainAttachNode || nodeName == TimeoutAttachNode { if nodeName == UncertainAttachNode || nodeName == TimeoutAttachNode {
return "", fmt.Errorf("Timed out to attach volume %q to node %q", volumeName, nodeName) return "", fmt.Errorf("timed out to attach volume %q to node %q", volumeName, nodeName)
} }
return "/dev/vdb-test", nil return "/dev/vdb-test", nil
} }
@ -1070,7 +1070,7 @@ func (fv *FakeVolume) Detach(volumeName string, nodeName types.NodeName) error {
node := string(nodeName) node := string(nodeName)
volumeNodes, exist := fv.VolumesAttached[volumeName] volumeNodes, exist := fv.VolumesAttached[volumeName]
if !exist || !volumeNodes.Has(node) { if !exist || !volumeNodes.Has(node) {
return fmt.Errorf("Trying to detach volume %q that is not attached to the node %q", volumeName, node) return fmt.Errorf("trying to detach volume %q that is not attached to the node %q", volumeName, node)
} }
volumeNodes.Delete(node) volumeNodes.Delete(node)

View File

@ -54,7 +54,7 @@ func (handler *mockOsIOHandler) ReadFile(filename string) ([]byte, error) {
return []byte("target2"), nil return []byte("target2"), nil
} }
} }
return nil, errors.New("Not Implemented for Mock") return nil, errors.New("not Implemented for Mock")
} }
func (handler *mockOsIOHandler) ReadDir(dirname string) ([]os.FileInfo, error) { func (handler *mockOsIOHandler) ReadDir(dirname string) ([]os.FileInfo, error) {
@ -139,7 +139,7 @@ func (handler *mockOsIOHandler) ReadDir(dirname string) ([]os.FileInfo, error) {
} }
return []os.FileInfo{f1}, nil return []os.FileInfo{f1}, nil
} }
return nil, errors.New("Not Implemented for Mock") return nil, errors.New("not Implemented for Mock")
} }
func (handler *mockOsIOHandler) Lstat(name string) (os.FileInfo, error) { func (handler *mockOsIOHandler) Lstat(name string) (os.FileInfo, error) {
@ -154,7 +154,7 @@ func (handler *mockOsIOHandler) Lstat(name string) (os.FileInfo, error) {
if dev, ok := links[name]; ok { if dev, ok := links[name]; ok {
return &fakeFileInfo{name: dev}, nil return &fakeFileInfo{name: dev}, nil
} }
return nil, errors.New("Not Implemented for Mock") return nil, errors.New("not Implemented for Mock")
} }
func (handler *mockOsIOHandler) EvalSymlinks(path string) (string, error) { func (handler *mockOsIOHandler) EvalSymlinks(path string) (string, error) {
@ -172,7 +172,7 @@ func (handler *mockOsIOHandler) EvalSymlinks(path string) (string, error) {
} }
func (handler *mockOsIOHandler) WriteFile(filename string, data []byte, perm os.FileMode) error { func (handler *mockOsIOHandler) WriteFile(filename string, data []byte, perm os.FileMode) error {
return errors.New("Not Implemented for Mock") return errors.New("not Implemented for Mock")
} }
type fakeFileInfo struct { type fakeFileInfo struct {

View File

@ -113,12 +113,12 @@ func testBackingDev1(testcase backingDevTest) error {
return err return err
} }
if testcase.expectFailure { if testcase.expectFailure {
return fmt.Errorf("Path %s expected to fail; succeeded and got %s", testcase.path, backingDev) return fmt.Errorf("path %s expected to fail; succeeded and got %s", testcase.path, backingDev)
} }
if backingDev == testcase.expectedResult { if backingDev == testcase.expectedResult {
return nil return nil
} }
return fmt.Errorf("Mismatch: path %s expects mountpoint %s got %s", testcase.path, testcase.expectedResult, backingDev) return fmt.Errorf("mismatch: path %s expects mountpoint %s got %s", testcase.path, testcase.expectedResult, backingDev)
} }
func TestBackingDev(t *testing.T) { func TestBackingDev(t *testing.T) {
@ -332,7 +332,7 @@ func (v testVolumeQuota) SetQuotaOnDir(dir string, id common.QuotaID, _ int64) e
} }
oid, ok := testQuotaIDMap[dir] oid, ok := testQuotaIDMap[dir]
if ok && id != oid { if ok && id != oid {
return fmt.Errorf("Directory %s already has a quota applied", dir) return fmt.Errorf("directory %s already has a quota applied", dir)
} }
testQuotaIDMap[dir] = id testQuotaIDMap[dir] = id
testIDQuotaMap[id] = dir testIDQuotaMap[id] = dir
@ -344,7 +344,7 @@ func (v testVolumeQuota) GetQuotaOnDir(path string) (common.QuotaID, error) {
if ok { if ok {
return id, nil return id, nil
} }
return common.BadQuotaID, fmt.Errorf("No quota available for %s", path) return common.BadQuotaID, fmt.Errorf("no quota available for %s", path)
} }
func (v testVolumeQuota) QuotaIDIsInUse(id common.QuotaID) (bool, error) { func (v testVolumeQuota) QuotaIDIsInUse(id common.QuotaID) (bool, error) {

View File

@ -1056,7 +1056,7 @@ func TestSafeOpen(t *testing.T) {
socketFile, socketError := createSocketFile(base) socketFile, socketError := createSocketFile(base)
if socketError != nil { if socketError != nil {
return fmt.Errorf("Error preparing socket file %s with %v", socketFile, socketError) return fmt.Errorf("error preparing socket file %s with %w", socketFile, socketError)
} }
return nil return nil
}, },
@ -1069,7 +1069,7 @@ func TestSafeOpen(t *testing.T) {
testSocketFile, socketError := createSocketFile(base) testSocketFile, socketError := createSocketFile(base)
if socketError != nil { if socketError != nil {
return fmt.Errorf("Error preparing socket file %s with %v", testSocketFile, socketError) return fmt.Errorf("error preparing socket file %s with %w", testSocketFile, socketError)
} }
return nil return nil
}, },
@ -1262,7 +1262,7 @@ func validateDirEmpty(dir string) error {
} }
if len(files) != 0 { if len(files) != 0 {
return fmt.Errorf("Directory %q is not empty", dir) return fmt.Errorf("directory %q is not empty", dir)
} }
return nil return nil
} }

View File

@ -130,7 +130,7 @@ func GetSecretForPod(pod *v1.Pod, secretName string, kubeClient clientset.Interf
func GetSecretForPV(secretNamespace, secretName, volumePluginName string, kubeClient clientset.Interface) (map[string]string, error) { func GetSecretForPV(secretNamespace, secretName, volumePluginName string, kubeClient clientset.Interface) (map[string]string, error) {
secret := make(map[string]string) secret := make(map[string]string)
if kubeClient == nil { if kubeClient == nil {
return secret, fmt.Errorf("Cannot get kube client") return secret, fmt.Errorf("cannot get kube client")
} }
secrets, err := kubeClient.CoreV1().Secrets(secretNamespace).Get(context.TODO(), secretName, metav1.GetOptions{}) secrets, err := kubeClient.CoreV1().Secrets(secretNamespace).Get(context.TODO(), secretName, metav1.GetOptions{})
if err != nil { if err != nil {

View File

@ -88,9 +88,9 @@ func TestAttachDetach(t *testing.T) {
diskName := "[local] volumes/test" diskName := "[local] volumes/test"
nodeName := types.NodeName("host") nodeName := types.NodeName("host")
spec := createVolSpec(diskName) spec := createVolSpec(diskName)
attachError := errors.New("Fake attach error") attachError := errors.New("fake attach error")
detachError := errors.New("Fake detach error") detachError := errors.New("fake detach error")
diskCheckError := errors.New("Fake DiskIsAttached error") diskCheckError := errors.New("fake DiskIsAttached error")
tests := []testcase{ tests := []testcase{
// Successful Attach call // Successful Attach call
{ {
@ -250,17 +250,17 @@ func (testcase *testcase) AttachDisk(diskName string, storagePolicyName string,
// testcase.attach looks uninitialized, test did not expect to call // testcase.attach looks uninitialized, test did not expect to call
// AttachDisk // AttachDisk
testcase.t.Errorf("Unexpected AttachDisk call!") testcase.t.Errorf("Unexpected AttachDisk call!")
return "", errors.New("Unexpected AttachDisk call!") return "", errors.New("unexpected AttachDisk call")
} }
if expected.diskName != diskName { if expected.diskName != diskName {
testcase.t.Errorf("Unexpected AttachDisk call: expected diskName %s, got %s", expected.diskName, diskName) testcase.t.Errorf("Unexpected AttachDisk call: expected diskName %s, got %s", expected.diskName, diskName)
return "", fmt.Errorf(`Unexpected AttachDisk call: %w`, diskNameErr) return "", fmt.Errorf(`unexpected AttachDisk call: %w`, diskNameErr)
} }
if expected.nodeName != nodeName { if expected.nodeName != nodeName {
testcase.t.Errorf("Unexpected AttachDisk call: expected nodeName %s, got %s", expected.nodeName, nodeName) testcase.t.Errorf("Unexpected AttachDisk call: expected nodeName %s, got %s", expected.nodeName, nodeName)
return "", fmt.Errorf(`Unexpected AttachDisk call: %w`, nodeNameErr) return "", fmt.Errorf(`unexpected AttachDisk call: %w`, nodeNameErr)
} }
klog.V(4).Infof("AttachDisk call: %s, %s, returning %q, %v", diskName, nodeName, expected.retDeviceUUID, expected.ret) klog.V(4).Infof("AttachDisk call: %s, %s, returning %q, %v", diskName, nodeName, expected.retDeviceUUID, expected.ret)
@ -275,17 +275,17 @@ func (testcase *testcase) DetachDisk(diskName string, nodeName types.NodeName) e
// testcase.detach looks uninitialized, test did not expect to call // testcase.detach looks uninitialized, test did not expect to call
// DetachDisk // DetachDisk
testcase.t.Errorf("Unexpected DetachDisk call!") testcase.t.Errorf("Unexpected DetachDisk call!")
return errors.New("Unexpected DetachDisk call!") return errors.New("unexpected DetachDisk call")
} }
if expected.diskName != diskName { if expected.diskName != diskName {
testcase.t.Errorf("Unexpected DetachDisk call: expected diskName %s, got %s", expected.diskName, diskName) testcase.t.Errorf("Unexpected DetachDisk call: expected diskName %s, got %s", expected.diskName, diskName)
return fmt.Errorf(`Unexpected DetachDisk call: %w`, diskNameErr) return fmt.Errorf(`unexpected DetachDisk call: %w`, diskNameErr)
} }
if expected.nodeName != nodeName { if expected.nodeName != nodeName {
testcase.t.Errorf("Unexpected DetachDisk call: expected nodeName %s, got %s", expected.nodeName, nodeName) testcase.t.Errorf("Unexpected DetachDisk call: expected nodeName %s, got %s", expected.nodeName, nodeName)
return fmt.Errorf(`Unexpected DetachDisk call: %w`, nodeNameErr) return fmt.Errorf(`unexpected DetachDisk call: %w`, nodeNameErr)
} }
klog.V(4).Infof("DetachDisk call: %s, %s, returning %v", diskName, nodeName, expected.ret) klog.V(4).Infof("DetachDisk call: %s, %s, returning %v", diskName, nodeName, expected.ret)
@ -300,17 +300,17 @@ func (testcase *testcase) DiskIsAttached(diskName string, nodeName types.NodeNam
// testcase.diskIsAttached looks uninitialized, test did not expect to // testcase.diskIsAttached looks uninitialized, test did not expect to
// call DiskIsAttached // call DiskIsAttached
testcase.t.Errorf("Unexpected DiskIsAttached call!") testcase.t.Errorf("Unexpected DiskIsAttached call!")
return false, diskName, errors.New("Unexpected DiskIsAttached call!") return false, diskName, errors.New("unexpected DiskIsAttached call")
} }
if expected.diskName != diskName { if expected.diskName != diskName {
testcase.t.Errorf("Unexpected DiskIsAttached call: expected diskName %s, got %s", expected.diskName, diskName) testcase.t.Errorf("Unexpected DiskIsAttached call: expected diskName %s, got %s", expected.diskName, diskName)
return false, diskName, fmt.Errorf(`Unexpected DiskIsAttached call: %w`, diskNameErr) return false, diskName, fmt.Errorf(`unexpected DiskIsAttached call: %w`, diskNameErr)
} }
if expected.nodeName != nodeName { if expected.nodeName != nodeName {
testcase.t.Errorf("Unexpected DiskIsAttached call: expected nodeName %s, got %s", expected.nodeName, nodeName) testcase.t.Errorf("Unexpected DiskIsAttached call: expected nodeName %s, got %s", expected.nodeName, nodeName)
return false, diskName, fmt.Errorf(`Unexpected DiskIsAttached call: %w`, nodeNameErr) return false, diskName, fmt.Errorf(`unexpected DiskIsAttached call: %w`, nodeNameErr)
} }
klog.V(4).Infof("DiskIsAttached call: %s, %s, returning %v, %v", diskName, nodeName, expected.isAttached, expected.ret) klog.V(4).Infof("DiskIsAttached call: %s, %s, returning %v, %v", diskName, nodeName, expected.isAttached, expected.ret)
@ -319,13 +319,13 @@ func (testcase *testcase) DiskIsAttached(diskName string, nodeName types.NodeNam
} }
func (testcase *testcase) DisksAreAttached(nodeVolumes map[types.NodeName][]string) (map[types.NodeName]map[string]bool, error) { func (testcase *testcase) DisksAreAttached(nodeVolumes map[types.NodeName][]string) (map[types.NodeName]map[string]bool, error) {
return nil, errors.New("Not implemented") return nil, errors.New("not implemented")
} }
func (testcase *testcase) CreateVolume(volumeOptions *vclib.VolumeOptions) (volumePath string, err error) { func (testcase *testcase) CreateVolume(volumeOptions *vclib.VolumeOptions) (volumePath string, err error) {
return "", errors.New("Not implemented") return "", errors.New("not implemented")
} }
func (testcase *testcase) DeleteVolume(vmDiskPath string) error { func (testcase *testcase) DeleteVolume(vmDiskPath string) error {
return errors.New("Not implemented") return errors.New("not implemented")
} }

View File

@ -27,7 +27,7 @@ import (
func verifyDevicePath(path string) (string, error) { func verifyDevicePath(path string) (string, error) {
if pathExists, err := mount.PathExists(path); err != nil { if pathExists, err := mount.PathExists(path); err != nil {
return "", fmt.Errorf("Error checking if path exists: %v", err) return "", fmt.Errorf("error checking if path exists: %w", err)
} else if pathExists { } else if pathExists {
return path, nil return path, nil
} }