From 64646677a4bbd56033a5d45c5417cc973ef063b7 Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Mon, 13 May 2019 10:17:17 +0530 Subject: [PATCH] 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 --- pkg/cephfs/util.go | 4 ++-- pkg/rbd/controllerserver.go | 24 ++++++++++++------------ pkg/rbd/nodeserver.go | 4 ++-- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/pkg/cephfs/util.go b/pkg/cephfs/util.go index 8b4426958d49..333e237cc9f1 100644 --- a/pkg/cephfs/util.go +++ b/pkg/cephfs/util.go @@ -109,12 +109,12 @@ func (cs *ControllerServer) validateCreateVolumeRequest(req *csi.CreateVolumeReq } 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() 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 { diff --git a/pkg/rbd/controllerserver.go b/pkg/rbd/controllerserver.go index 3beb87d75453..0d477ea1aec3 100644 --- a/pkg/rbd/controllerserver.go +++ b/pkg/rbd/controllerserver.go @@ -82,10 +82,10 @@ func (cs *ControllerServer) validateVolumeReq(req *csi.CreateVolumeRequest) erro } // Check sanity of request Name, Volume Capabilities 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 { - return status.Error(codes.InvalidArgument, "Volume Capabilities cannot be empty") + return status.Error(codes.InvalidArgument, "volume Capabilities cannot be empty") } return nil } @@ -177,7 +177,7 @@ func (cs *ControllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol }, }, nil } - return nil, status.Errorf(codes.AlreadyExists, "Volume with the same name: %s but with different size already exist", req.GetName()) + return nil, status.Errorf(codes.AlreadyExists, "volume with the same name: %s but with different size already exist", req.GetName()) } rbdVol, err := parseVolCreateRequest(req) @@ -235,12 +235,12 @@ func (cs *ControllerServer) checkRBDStatus(rbdVol *rbdVolume, req *csi.CreateVol func (cs *ControllerServer) checkSnapshot(req *csi.CreateVolumeRequest, rbdVol *rbdVolume) error { snapshot := req.VolumeContentSource.GetSnapshot() 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() 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{} @@ -400,7 +400,7 @@ func (cs *ControllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateS }, }, nil } - return nil, status.Errorf(codes.AlreadyExists, "Snapshot with the same name: %s but with different source volume id already exist", req.GetName()) + return nil, status.Errorf(codes.AlreadyExists, "snapshot with the same name: %s but with different source volume id already exist", req.GetName()) } rbdSnap, err := getRBDSnapshotOptions(req.GetParameters()) @@ -413,7 +413,7 @@ func (cs *ControllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateS uniqueID := uuid.NewUUID().String() rbdVolume, err := getRBDVolumeByID(req.GetSourceVolumeId()) if err != nil { - return nil, status.Errorf(codes.NotFound, "Source Volume ID %s cannot found", req.GetSourceVolumeId()) + return nil, status.Errorf(codes.NotFound, "source Volume ID %s cannot found", req.GetSourceVolumeId()) } if !hasSnapshotFeature(rbdVolume.ImageFeatures) { return nil, status.Errorf(codes.InvalidArgument, "volume(%s) has not snapshot feature(layering)", req.GetSourceVolumeId()) @@ -470,10 +470,10 @@ func (cs *ControllerServer) validateSnapshotReq(req *csi.CreateSnapshotRequest) // Check sanity of request Snapshot Name, Source Volume Id 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 { - return status.Error(codes.InvalidArgument, "Source Volume ID cannot be empty") + return status.Error(codes.InvalidArgument, "source Volume ID cannot be empty") } return nil } @@ -523,7 +523,7 @@ func (cs *ControllerServer) DeleteSnapshot(ctx context.Context, req *csi.DeleteS snapshotID := req.GetSnapshotId() 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) @@ -581,7 +581,7 @@ func (cs *ControllerServer) ListSnapshots(ctx context.Context, req *csi.ListSnap if rbdSnap, ok := rbdSnapshots[snapshotID]; ok { // if source volume ID also set, check source volume id on the cache. if len(sourceVolumeID) != 0 && rbdSnap.SourceVolumeID != sourceVolumeID { - return nil, status.Errorf(codes.Unknown, "Requested Source Volume ID %s is different from %s", sourceVolumeID, rbdSnap.SourceVolumeID) + return nil, status.Errorf(codes.Unknown, "requested Source Volume ID %s is different from %s", sourceVolumeID, rbdSnap.SourceVolumeID) } return &csi.ListSnapshotsResponse{ Entries: []*csi.ListSnapshotsResponse_Entry{ @@ -599,7 +599,7 @@ func (cs *ControllerServer) ListSnapshots(ctx context.Context, req *csi.ListSnap }, }, nil } - return nil, status.Errorf(codes.NotFound, "Snapshot ID %s cannot found", snapshotID) + return nil, status.Errorf(codes.NotFound, "snapshot ID %s cannot found", snapshotID) } diff --git a/pkg/rbd/nodeserver.go b/pkg/rbd/nodeserver.go index 5b5cffaf728e..0ce9072fc6ad 100644 --- a/pkg/rbd/nodeserver.go +++ b/pkg/rbd/nodeserver.go @@ -23,7 +23,7 @@ import ( "regexp" "strings" - "github.com/ceph/ceph-csi/pkg/csi-common" + csicommon "github.com/ceph/ceph-csi/pkg/csi-common" "github.com/container-storage-interface/spec/lib/go/csi" "golang.org/x/net/context" @@ -207,7 +207,7 @@ func (ns *NodeServer) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpu if notMnt { // TODO should consider deleting path instead of returning error, // 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)