Skip to content

Commit

Permalink
Fix error string as per golang standard
Browse files Browse the repository at this point in the history
Error string should not be capatalized
https://github.com/golang/go/wiki/CodeReviewComments#error-strings

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
  • Loading branch information
Madhu-1 committed May 13, 2019
1 parent 3f35bfd commit 6464667
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions pkg/cephfs/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
24 changes: 12 additions & 12 deletions pkg/rbd/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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{}
Expand Down Expand Up @@ -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())
Expand All @@ -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())
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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{
Expand All @@ -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)

}

Expand Down
4 changes: 2 additions & 2 deletions pkg/rbd/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 6464667

Please sign in to comment.