update static check failed from pkg/volume/rbd

remove field from staticcheck_failures
This commit is contained in:
haleygo
2020-06-24 15:48:00 +08:00
parent c90427d42e
commit d6cf8d3e57
5 changed files with 24 additions and 26 deletions

View File

@@ -37,7 +37,6 @@ import (
"k8s.io/apimachinery/pkg/util/uuid"
clientset "k8s.io/client-go/kubernetes"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util"
volutil "k8s.io/kubernetes/pkg/volume/util"
"k8s.io/kubernetes/pkg/volume/util/volumepathhandler"
)
@@ -199,7 +198,7 @@ func (plugin *rbdPlugin) ExpandVolumeDevice(spec *volume.Spec, newSize resource.
}
func (plugin *rbdPlugin) NodeExpand(resizeOptions volume.NodeResizeOptions) (bool, error) {
fsVolume, err := util.CheckVolumeModeFilesystem(resizeOptions.VolumeSpec)
fsVolume, err := volutil.CheckVolumeModeFilesystem(resizeOptions.VolumeSpec)
if err != nil {
return false, fmt.Errorf("error checking VolumeMode: %v", err)
}
@@ -268,11 +267,11 @@ func (plugin *rbdPlugin) createMounterFromVolumeSpecAndPod(spec *volume.Spec, po
// if secret is provideded, retrieve it
kubeClient := plugin.host.GetKubeClient()
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{})
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: %v", secretNs, secretName, err)
return nil, err
}
for _, data := range secrets.Data {
@@ -301,11 +300,11 @@ func (plugin *rbdPlugin) NewMounter(spec *volume.Spec, pod *v1.Pod, _ volume.Vol
// if secret is provideded, retrieve it
kubeClient := plugin.host.GetKubeClient()
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{})
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: %v", secretNs, secretName, err)
return nil, err
}
for _, data := range secrets.Data {
@@ -483,11 +482,11 @@ func (plugin *rbdPlugin) NewBlockVolumeMapper(spec *volume.Spec, pod *v1.Pod, _
// if secret is provideded, retrieve it
kubeClient := plugin.host.GetKubeClient()
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{})
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: %v", secretNs, secretName, err)
return nil, err
}
for _, data := range secrets.Data {
@@ -862,7 +861,7 @@ func (c *rbdUnmounter) TearDown() error {
func (c *rbdUnmounter) TearDownAt(dir string) error {
klog.V(4).Infof("rbd: attempting to teardown at %s", dir)
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 {
klog.Warningf("Warning: Unmount skipped because path does not exist: %v", dir)
return nil
@@ -996,7 +995,7 @@ func getVolumeSourceMonitors(spec *volume.Spec) ([]string, error) {
return spec.PersistentVolume.Spec.RBD.CephMonitors, nil
}
return nil, fmt.Errorf("Spec does not reference a RBD volume type")
return nil, fmt.Errorf("spec does not reference a RBD volume type")
}
func getVolumeSourceImage(spec *volume.Spec) (string, error) {
@@ -1007,7 +1006,7 @@ func getVolumeSourceImage(spec *volume.Spec) (string, error) {
return spec.PersistentVolume.Spec.RBD.RBDImage, nil
}
return "", fmt.Errorf("Spec does not reference a RBD volume type")
return "", fmt.Errorf("spec does not reference a RBD volume type")
}
func getVolumeSourceFSType(spec *volume.Spec) (string, error) {
@@ -1018,7 +1017,7 @@ func getVolumeSourceFSType(spec *volume.Spec) (string, error) {
return spec.PersistentVolume.Spec.RBD.FSType, nil
}
return "", fmt.Errorf("Spec does not reference a RBD volume type")
return "", fmt.Errorf("spec does not reference a RBD volume type")
}
func getVolumeSourcePool(spec *volume.Spec) (string, error) {
@@ -1029,7 +1028,7 @@ func getVolumeSourcePool(spec *volume.Spec) (string, error) {
return spec.PersistentVolume.Spec.RBD.RBDPool, nil
}
return "", fmt.Errorf("Spec does not reference a RBD volume type")
return "", fmt.Errorf("spec does not reference a RBD volume type")
}
func getVolumeSourceUser(spec *volume.Spec) (string, error) {
@@ -1040,7 +1039,7 @@ func getVolumeSourceUser(spec *volume.Spec) (string, error) {
return spec.PersistentVolume.Spec.RBD.RadosUser, nil
}
return "", fmt.Errorf("Spec does not reference a RBD volume type")
return "", fmt.Errorf("spec does not reference a RBD volume type")
}
func getVolumeSourceKeyRing(spec *volume.Spec) (string, error) {
@@ -1051,7 +1050,7 @@ func getVolumeSourceKeyRing(spec *volume.Spec) (string, error) {
return spec.PersistentVolume.Spec.RBD.Keyring, nil
}
return "", fmt.Errorf("Spec does not reference a RBD volume type")
return "", fmt.Errorf("spec does not reference a RBD volume type")
}
func getVolumeSourceReadOnly(spec *volume.Spec) (bool, error) {
@@ -1064,7 +1063,7 @@ func getVolumeSourceReadOnly(spec *volume.Spec) (bool, error) {
return spec.ReadOnly, nil
}
return false, fmt.Errorf("Spec does not reference a RBD volume type")
return false, fmt.Errorf("spec does not reference a RBD volume type")
}
func getVolumeAccessModes(spec *volume.Spec) ([]v1.PersistentVolumeAccessMode, error) {
@@ -1073,7 +1072,7 @@ func getVolumeAccessModes(spec *volume.Spec) ([]v1.PersistentVolumeAccessMode, e
if spec.PersistentVolume.Spec.RBD != nil {
return spec.PersistentVolume.Spec.AccessModes, nil
}
return nil, fmt.Errorf("Spec does not reference a RBD volume type")
return nil, fmt.Errorf("spec does not reference a RBD volume type")
}
return nil, nil
@@ -1124,5 +1123,5 @@ func getSecretNameAndNamespace(spec *volume.Spec, defaultNamespace string) (stri
}
return "", "", nil
}
return "", "", fmt.Errorf("Spec does not reference an RBD volume type")
return "", "", fmt.Errorf("spec does not reference an RBD volume type")
}