diff --git a/pkg/cephfs/util.go b/pkg/cephfs/util.go index 4c0e1b066..d5b8a1360 100644 --- a/pkg/cephfs/util.go +++ b/pkg/cephfs/util.go @@ -19,6 +19,7 @@ package cephfs import ( "bytes" "encoding/json" + "errors" "fmt" "os/exec" @@ -139,19 +140,19 @@ func (cs *controllerServer) validateDeleteVolumeRequest(req *csi.DeleteVolumeReq func validateNodeStageVolumeRequest(req *csi.NodeStageVolumeRequest) error { if req.GetVolumeCapability() == nil { - return fmt.Errorf("volume capability missing in request") + return errors.New("volume capability missing in request") } if req.GetVolumeId() == "" { - return fmt.Errorf("volume ID missing in request") + return errors.New("volume ID missing in request") } if req.GetStagingTargetPath() == "" { - return fmt.Errorf("staging target path missing in request") + return errors.New("staging target path missing in request") } if req.GetSecrets() == nil || len(req.GetSecrets()) == 0 { - return fmt.Errorf("stage secrets cannot be nil or empty") + return errors.New("stage secrets cannot be nil or empty") } return nil @@ -159,11 +160,11 @@ func validateNodeStageVolumeRequest(req *csi.NodeStageVolumeRequest) error { func validateNodeUnstageVolumeRequest(req *csi.NodeUnstageVolumeRequest) error { if req.GetVolumeId() == "" { - return fmt.Errorf("volume ID missing in request") + return errors.New("volume ID missing in request") } if req.GetStagingTargetPath() == "" { - return fmt.Errorf("staging target path missing in request") + return errors.New("staging target path missing in request") } return nil @@ -171,15 +172,15 @@ func validateNodeUnstageVolumeRequest(req *csi.NodeUnstageVolumeRequest) error { func validateNodePublishVolumeRequest(req *csi.NodePublishVolumeRequest) error { if req.GetVolumeCapability() == nil { - return fmt.Errorf("volume capability missing in request") + return errors.New("volume capability missing in request") } if req.GetVolumeId() == "" { - return fmt.Errorf("volume ID missing in request") + return errors.New("volume ID missing in request") } if req.GetTargetPath() == "" { - return fmt.Errorf("varget path missing in request") + return errors.New("varget path missing in request") } return nil @@ -187,11 +188,11 @@ func validateNodePublishVolumeRequest(req *csi.NodePublishVolumeRequest) error { func validateNodeUnpublishVolumeRequest(req *csi.NodeUnpublishVolumeRequest) error { if req.GetVolumeId() == "" { - return fmt.Errorf("volume ID missing in request") + return errors.New("volume ID missing in request") } if req.GetTargetPath() == "" { - return fmt.Errorf("target path missing in request") + return errors.New("target path missing in request") } return nil diff --git a/pkg/cephfs/volumemounter.go b/pkg/cephfs/volumemounter.go index 6a5e696ed..ead40fabe 100644 --- a/pkg/cephfs/volumemounter.go +++ b/pkg/cephfs/volumemounter.go @@ -18,6 +18,7 @@ package cephfs import ( "bytes" + "errors" "fmt" "os" "os/exec" @@ -47,7 +48,7 @@ func loadAvailableMounters() error { } if len(availableMounters) == 0 { - return fmt.Errorf("no ceph mounters found on system") + return errors.New("no ceph mounters found on system") } return nil diff --git a/pkg/rbd/rbd_util.go b/pkg/rbd/rbd_util.go index 10e5c174f..03be2b327 100644 --- a/pkg/rbd/rbd_util.go +++ b/pkg/rbd/rbd_util.go @@ -102,7 +102,7 @@ func getMon(pOpts *rbdVolume, credentials map[string]string) (string, error) { // if mons are set in secret, retrieve them if len(pOpts.MonValueFromSecret) == 0 { // yet another sanity check - return "", fmt.Errorf("either monitors or monValueFromSecret must be set") + return "", errors.New("either monitors or monValueFromSecret must be set") } val, ok := credentials[pOpts.MonValueFromSecret] if !ok { @@ -344,7 +344,7 @@ func getSnapMon(pOpts *rbdSnapshot, credentials map[string]string) (string, erro // if mons are set in secret, retrieve them if len(pOpts.MonValueFromSecret) == 0 { // yet another sanity check - return "", fmt.Errorf("either monitors or monValueFromSecret must be set") + return "", errors.New("either monitors or monValueFromSecret must be set") } val, ok := credentials[pOpts.MonValueFromSecret] if !ok {