mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-04-11 18:13:00 +00:00
user errors.New if error formatting is not required
Signed-off-by: Madhu Rajanna <mrajanna@redhat.com>
This commit is contained in:
parent
17f5c0a7ce
commit
e42e66ff30
@ -19,6 +19,7 @@ package cephfs
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
|
||||||
@ -139,19 +140,19 @@ func (cs *controllerServer) validateDeleteVolumeRequest(req *csi.DeleteVolumeReq
|
|||||||
|
|
||||||
func validateNodeStageVolumeRequest(req *csi.NodeStageVolumeRequest) error {
|
func validateNodeStageVolumeRequest(req *csi.NodeStageVolumeRequest) error {
|
||||||
if req.GetVolumeCapability() == nil {
|
if req.GetVolumeCapability() == nil {
|
||||||
return fmt.Errorf("volume capability missing in request")
|
return errors.New("volume capability missing in request")
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.GetVolumeId() == "" {
|
if req.GetVolumeId() == "" {
|
||||||
return fmt.Errorf("volume ID missing in request")
|
return errors.New("volume ID missing in request")
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.GetStagingTargetPath() == "" {
|
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 {
|
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
|
return nil
|
||||||
@ -159,11 +160,11 @@ func validateNodeStageVolumeRequest(req *csi.NodeStageVolumeRequest) error {
|
|||||||
|
|
||||||
func validateNodeUnstageVolumeRequest(req *csi.NodeUnstageVolumeRequest) error {
|
func validateNodeUnstageVolumeRequest(req *csi.NodeUnstageVolumeRequest) error {
|
||||||
if req.GetVolumeId() == "" {
|
if req.GetVolumeId() == "" {
|
||||||
return fmt.Errorf("volume ID missing in request")
|
return errors.New("volume ID missing in request")
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.GetStagingTargetPath() == "" {
|
if req.GetStagingTargetPath() == "" {
|
||||||
return fmt.Errorf("staging target path missing in request")
|
return errors.New("staging target path missing in request")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@ -171,15 +172,15 @@ func validateNodeUnstageVolumeRequest(req *csi.NodeUnstageVolumeRequest) error {
|
|||||||
|
|
||||||
func validateNodePublishVolumeRequest(req *csi.NodePublishVolumeRequest) error {
|
func validateNodePublishVolumeRequest(req *csi.NodePublishVolumeRequest) error {
|
||||||
if req.GetVolumeCapability() == nil {
|
if req.GetVolumeCapability() == nil {
|
||||||
return fmt.Errorf("volume capability missing in request")
|
return errors.New("volume capability missing in request")
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.GetVolumeId() == "" {
|
if req.GetVolumeId() == "" {
|
||||||
return fmt.Errorf("volume ID missing in request")
|
return errors.New("volume ID missing in request")
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.GetTargetPath() == "" {
|
if req.GetTargetPath() == "" {
|
||||||
return fmt.Errorf("varget path missing in request")
|
return errors.New("varget path missing in request")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@ -187,11 +188,11 @@ func validateNodePublishVolumeRequest(req *csi.NodePublishVolumeRequest) error {
|
|||||||
|
|
||||||
func validateNodeUnpublishVolumeRequest(req *csi.NodeUnpublishVolumeRequest) error {
|
func validateNodeUnpublishVolumeRequest(req *csi.NodeUnpublishVolumeRequest) error {
|
||||||
if req.GetVolumeId() == "" {
|
if req.GetVolumeId() == "" {
|
||||||
return fmt.Errorf("volume ID missing in request")
|
return errors.New("volume ID missing in request")
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.GetTargetPath() == "" {
|
if req.GetTargetPath() == "" {
|
||||||
return fmt.Errorf("target path missing in request")
|
return errors.New("target path missing in request")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -18,6 +18,7 @@ package cephfs
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
@ -47,7 +48,7 @@ func loadAvailableMounters() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(availableMounters) == 0 {
|
if len(availableMounters) == 0 {
|
||||||
return fmt.Errorf("no ceph mounters found on system")
|
return errors.New("no ceph mounters found on system")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -102,7 +102,7 @@ func getMon(pOpts *rbdVolume, credentials map[string]string) (string, error) {
|
|||||||
// if mons are set in secret, retrieve them
|
// if mons are set in secret, retrieve them
|
||||||
if len(pOpts.MonValueFromSecret) == 0 {
|
if len(pOpts.MonValueFromSecret) == 0 {
|
||||||
// yet another sanity check
|
// 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]
|
val, ok := credentials[pOpts.MonValueFromSecret]
|
||||||
if !ok {
|
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 mons are set in secret, retrieve them
|
||||||
if len(pOpts.MonValueFromSecret) == 0 {
|
if len(pOpts.MonValueFromSecret) == 0 {
|
||||||
// yet another sanity check
|
// 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]
|
val, ok := credentials[pOpts.MonValueFromSecret]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
Loading…
Reference in New Issue
Block a user