Fix error string as per golang standard

Error string should not be capatalized
https://github.com/golang/go/wiki/CodeReviewComments#error-strings

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna 2019-05-13 10:17:17 +05:30
parent 0e61098522
commit 74c1a75828
3 changed files with 23 additions and 23 deletions

View File

@ -106,12 +106,12 @@ func (cs *ControllerServer) validateCreateVolumeRequest(req *csi.CreateVolumeReq
} }
if req.GetName() == "" { if req.GetName() == "" {
return status.Error(codes.InvalidArgument, "Volume Name cannot be empty") return status.Error(codes.InvalidArgument, "volume Name cannot be empty")
} }
reqCaps := req.GetVolumeCapabilities() reqCaps := req.GetVolumeCapabilities()
if reqCaps == nil { if reqCaps == nil {
return status.Error(codes.InvalidArgument, "Volume Capabilities cannot be empty") return status.Error(codes.InvalidArgument, "volume Capabilities cannot be empty")
} }
for _, cap := range reqCaps { for _, cap := range reqCaps {

View File

@ -47,17 +47,17 @@ func (cs *ControllerServer) validateVolumeReq(req *csi.CreateVolumeRequest) erro
} }
// Check sanity of request Name, Volume Capabilities // Check sanity of request Name, Volume Capabilities
if len(req.Name) == 0 { if len(req.Name) == 0 {
return status.Error(codes.InvalidArgument, "Volume Name cannot be empty") return status.Error(codes.InvalidArgument, "volume Name cannot be empty")
} }
if req.VolumeCapabilities == nil { if req.VolumeCapabilities == nil {
return status.Error(codes.InvalidArgument, "Volume Capabilities cannot be empty") return status.Error(codes.InvalidArgument, "volume Capabilities cannot be empty")
} }
options := req.GetParameters() options := req.GetParameters()
if value, ok := options["clusterID"]; !ok || len(value) == 0 { if value, ok := options["clusterID"]; !ok || len(value) == 0 {
return status.Error(codes.InvalidArgument, "Missing or empty cluster ID to provision volume from") return status.Error(codes.InvalidArgument, "missing or empty cluster ID to provision volume from")
} }
if value, ok := options["pool"]; !ok || len(value) == 0 { if value, ok := options["pool"]; !ok || len(value) == 0 {
return status.Error(codes.InvalidArgument, "Missing or empty pool name to provision volume from") return status.Error(codes.InvalidArgument, "missing or empty pool name to provision volume from")
} }
return nil return nil
} }
@ -190,12 +190,12 @@ func (cs *ControllerServer) createBackingImage(rbdVol *rbdVolume, req *csi.Creat
func (cs *ControllerServer) checkSnapshot(req *csi.CreateVolumeRequest, rbdVol *rbdVolume) error { func (cs *ControllerServer) checkSnapshot(req *csi.CreateVolumeRequest, rbdVol *rbdVolume) error {
snapshot := req.VolumeContentSource.GetSnapshot() snapshot := req.VolumeContentSource.GetSnapshot()
if snapshot == nil { if snapshot == nil {
return status.Error(codes.InvalidArgument, "Volume Snapshot cannot be empty") return status.Error(codes.InvalidArgument, "volume Snapshot cannot be empty")
} }
snapshotID := snapshot.GetSnapshotId() snapshotID := snapshot.GetSnapshotId()
if len(snapshotID) == 0 { if len(snapshotID) == 0 {
return status.Error(codes.InvalidArgument, "Volume Snapshot ID cannot be empty") return status.Error(codes.InvalidArgument, "volume Snapshot ID cannot be empty")
} }
rbdSnap := &rbdSnapshot{} rbdSnap := &rbdSnapshot{}
@ -203,7 +203,7 @@ func (cs *ControllerServer) checkSnapshot(req *csi.CreateVolumeRequest, rbdVol *
if _, ok := err.(ErrSnapNotFound); !ok { if _, ok := err.(ErrSnapNotFound); !ok {
return status.Error(codes.Internal, err.Error()) return status.Error(codes.Internal, err.Error())
} }
return status.Error(codes.InvalidArgument, "Missing requested Snapshot ID") return status.Error(codes.InvalidArgument, "missing requested Snapshot ID")
} }
err := restoreSnapshot(rbdVol, rbdSnap, rbdVol.AdminID, req.GetSecrets()) err := restoreSnapshot(rbdVol, rbdSnap, rbdVol.AdminID, req.GetSecrets())
@ -224,7 +224,7 @@ func (cs *ControllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol
// For now the image get unconditionally deleted, but here retention policy can be checked // For now the image get unconditionally deleted, but here retention policy can be checked
volumeID := req.GetVolumeId() volumeID := req.GetVolumeId()
if volumeID == "" { if volumeID == "" {
return nil, status.Error(codes.InvalidArgument, "Empty volume ID in request") return nil, status.Error(codes.InvalidArgument, "empty volume ID in request")
} }
volumeIDMutex.LockKey(volumeID) volumeIDMutex.LockKey(volumeID)
defer func() { defer func() {
@ -287,11 +287,11 @@ func (cs *ControllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol
// are supported. // are supported.
func (cs *ControllerServer) ValidateVolumeCapabilities(ctx context.Context, req *csi.ValidateVolumeCapabilitiesRequest) (*csi.ValidateVolumeCapabilitiesResponse, error) { func (cs *ControllerServer) ValidateVolumeCapabilities(ctx context.Context, req *csi.ValidateVolumeCapabilitiesRequest) (*csi.ValidateVolumeCapabilitiesResponse, error) {
if req.GetVolumeId() == "" { if req.GetVolumeId() == "" {
return nil, status.Error(codes.InvalidArgument, "Empty volume ID in request") return nil, status.Error(codes.InvalidArgument, "empty volume ID in request")
} }
if len(req.VolumeCapabilities) == 0 { if len(req.VolumeCapabilities) == 0 {
return nil, status.Error(codes.InvalidArgument, "Empty volume capabilities in request") return nil, status.Error(codes.InvalidArgument, "empty volume capabilities in request")
} }
for _, cap := range req.VolumeCapabilities { for _, cap := range req.VolumeCapabilities {
@ -326,7 +326,7 @@ func (cs *ControllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateS
err := genVolFromVolID(rbdVol, req.GetSourceVolumeId(), req.GetSecrets()) err := genVolFromVolID(rbdVol, req.GetSourceVolumeId(), req.GetSecrets())
if err != nil { if err != nil {
if _, ok := err.(ErrImageNotFound); ok { if _, ok := err.(ErrImageNotFound); ok {
return nil, status.Errorf(codes.NotFound, "Source Volume ID %s not found", req.GetSourceVolumeId()) return nil, status.Errorf(codes.NotFound, "source Volume ID %s not found", req.GetSourceVolumeId())
} }
return nil, status.Errorf(codes.Internal, err.Error()) return nil, status.Errorf(codes.Internal, err.Error())
} }
@ -402,10 +402,10 @@ func (cs *ControllerServer) validateSnapshotReq(req *csi.CreateSnapshotRequest)
// Check sanity of request Snapshot Name, Source Volume Id // Check sanity of request Snapshot Name, Source Volume Id
if len(req.Name) == 0 { if len(req.Name) == 0 {
return status.Error(codes.InvalidArgument, "Snapshot Name cannot be empty") return status.Error(codes.InvalidArgument, "snapshot Name cannot be empty")
} }
if len(req.SourceVolumeId) == 0 { if len(req.SourceVolumeId) == 0 {
return status.Error(codes.InvalidArgument, "Source Volume ID cannot be empty") return status.Error(codes.InvalidArgument, "source Volume ID cannot be empty")
} }
return nil return nil
@ -467,7 +467,7 @@ func (cs *ControllerServer) DeleteSnapshot(ctx context.Context, req *csi.DeleteS
snapshotID := req.GetSnapshotId() snapshotID := req.GetSnapshotId()
if len(snapshotID) == 0 { if len(snapshotID) == 0 {
return nil, status.Error(codes.InvalidArgument, "Snapshot ID cannot be empty") return nil, status.Error(codes.InvalidArgument, "snapshot ID cannot be empty")
} }
snapshotIDMutex.LockKey(snapshotID) snapshotIDMutex.LockKey(snapshotID)

View File

@ -23,7 +23,7 @@ import (
"regexp" "regexp"
"strings" "strings"
"github.com/ceph/ceph-csi/pkg/csi-common" csicommon "github.com/ceph/ceph-csi/pkg/csi-common"
"github.com/ceph/ceph-csi/pkg/util" "github.com/ceph/ceph-csi/pkg/util"
"github.com/container-storage-interface/spec/lib/go/csi" "github.com/container-storage-interface/spec/lib/go/csi"
@ -46,15 +46,15 @@ type NodeServer struct {
func (ns *NodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolumeRequest) (*csi.NodePublishVolumeResponse, error) { func (ns *NodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolumeRequest) (*csi.NodePublishVolumeResponse, error) {
targetPath := req.GetTargetPath() targetPath := req.GetTargetPath()
if targetPath == "" { if targetPath == "" {
return nil, status.Error(codes.InvalidArgument, "Empty target path in request") return nil, status.Error(codes.InvalidArgument, "empty target path in request")
} }
if req.GetVolumeCapability() == nil { if req.GetVolumeCapability() == nil {
return nil, status.Error(codes.InvalidArgument, "Empty volume capability in request") return nil, status.Error(codes.InvalidArgument, "empty volume capability in request")
} }
if req.GetVolumeId() == "" { if req.GetVolumeId() == "" {
return nil, status.Error(codes.InvalidArgument, "Empty volume ID in request") return nil, status.Error(codes.InvalidArgument, "empty volume ID in request")
} }
targetPathMutex.LockKey(targetPath) targetPathMutex.LockKey(targetPath)
@ -190,11 +190,11 @@ func (ns *NodeServer) createTargetPath(targetPath string, isBlock bool) (bool, e
func (ns *NodeServer) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpublishVolumeRequest) (*csi.NodeUnpublishVolumeResponse, error) { func (ns *NodeServer) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpublishVolumeRequest) (*csi.NodeUnpublishVolumeResponse, error) {
targetPath := req.GetTargetPath() targetPath := req.GetTargetPath()
if targetPath == "" { if targetPath == "" {
return nil, status.Error(codes.InvalidArgument, "Empty target path in request") return nil, status.Error(codes.InvalidArgument, "empty target path in request")
} }
if req.GetVolumeId() == "" { if req.GetVolumeId() == "" {
return nil, status.Error(codes.InvalidArgument, "Empty volume ID in request") return nil, status.Error(codes.InvalidArgument, "empty volume ID in request")
} }
targetPathMutex.LockKey(targetPath) targetPathMutex.LockKey(targetPath)
@ -217,7 +217,7 @@ func (ns *NodeServer) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpu
if notMnt { if notMnt {
// TODO should consider deleting path instead of returning error, // TODO should consider deleting path instead of returning error,
// once all codes become ready for csi 1.0. // once all codes become ready for csi 1.0.
return nil, status.Error(codes.NotFound, "Volume not mounted") return nil, status.Error(codes.NotFound, "volume not mounted")
} }
devicePath, cnt, err := mount.GetDeviceNameFromMount(ns.mounter, targetPath) devicePath, cnt, err := mount.GetDeviceNameFromMount(ns.mounter, targetPath)