From 5983fedddb933586211431a8d7b3f74b8d74fd4e Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Mon, 4 Feb 2019 10:44:37 +0530 Subject: [PATCH] Fix issues found in gometalinter static check Signed-off-by: Madhu Rajanna --- pkg/cephfs/volumeoptions.go | 10 +++++----- pkg/rbd/controllerserver.go | 4 ++-- pkg/rbd/rbd_attach.go | 2 +- pkg/rbd/rbd_util.go | 8 ++++---- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/pkg/cephfs/volumeoptions.go b/pkg/cephfs/volumeoptions.go index 7ce6e86b3..eb092accf 100644 --- a/pkg/cephfs/volumeoptions.go +++ b/pkg/cephfs/volumeoptions.go @@ -34,7 +34,7 @@ type volumeOptions struct { func validateNonEmptyField(field, fieldName string) error { if field == "" { - return fmt.Errorf("Parameter '%s' cannot be empty", fieldName) + return fmt.Errorf("parameter '%s' cannot be empty", fieldName) } return nil @@ -53,7 +53,7 @@ func (o *volumeOptions) validate() error { } } else { if o.ProvisionVolume { - return fmt.Errorf("Non-empty field rootPath is in conflict with provisionVolume=true") + return fmt.Errorf("non-empty field rootPath is in conflict with provisionVolume=true") } } @@ -75,7 +75,7 @@ func (o *volumeOptions) validate() error { func extractOption(dest *string, optionLabel string, options map[string]string) error { opt, ok := options[optionLabel] if !ok { - return fmt.Errorf("Missing required field %s", optionLabel) + return fmt.Errorf("missing required field %s", optionLabel) } *dest = opt @@ -87,7 +87,7 @@ func validateMounter(m string) error { case volumeMounterFuse: case volumeMounterKernel: default: - return fmt.Errorf("Unknown mounter '%s'. Valid options are 'fuse' and 'kernel'", m) + return fmt.Errorf("unknown mounter '%s'. Valid options are 'fuse' and 'kernel'", m) } return nil @@ -134,7 +134,7 @@ func extractNewVolOpt(opts *volumeOptions, volOpt map[string]string) error { } if opts.ProvisionVolume, err = strconv.ParseBool(provisionVolumeBool); err != nil { - return fmt.Errorf("Failed to parse provisionVolume: %v", err) + return fmt.Errorf("failed to parse provisionVolume: %v", err) } if opts.ProvisionVolume { diff --git a/pkg/rbd/controllerserver.go b/pkg/rbd/controllerserver.go index 334f2f3a0..04db9a1bc 100644 --- a/pkg/rbd/controllerserver.go +++ b/pkg/rbd/controllerserver.go @@ -338,7 +338,7 @@ func (cs *ControllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateS return nil, status.Errorf(codes.NotFound, "Source Volume ID %s cannot found", req.GetSourceVolumeId()) } if !hasSnapshotFeature(rbdVolume.ImageFeatures) { - return nil, fmt.Errorf("Volume(%s) has not snapshot feature(layering)", req.GetSourceVolumeId()) + return nil, fmt.Errorf("volume(%s) has not snapshot feature(layering)", req.GetSourceVolumeId()) } rbdSnap.VolName = rbdVolume.VolName @@ -437,7 +437,7 @@ func (cs *ControllerServer) doSnapshot(rbdSnap *rbdSnapshot, secret map[string]s if err != nil { return fmt.Errorf("snapshot is created but failed to protect and delete snapshot: %v", err) } - return fmt.Errorf("Snapshot is created but failed to protect snapshot") + return fmt.Errorf("snapshot is created but failed to protect snapshot") } } return nil diff --git a/pkg/rbd/rbd_attach.go b/pkg/rbd/rbd_attach.go index 45bc22792..b593d0820 100644 --- a/pkg/rbd/rbd_attach.go +++ b/pkg/rbd/rbd_attach.go @@ -299,7 +299,7 @@ func createPath(volOpt *rbdVolume, userID string, creds map[string]string) (stri } devicePath, found := waitForPath(volOpt.Pool, image, 10, useNBD) if !found { - return "", fmt.Errorf("Could not map image %s, Timeout after 10s", imagePath) + return "", fmt.Errorf("could not map image %s, Timeout after 10s", imagePath) } return devicePath, nil } diff --git a/pkg/rbd/rbd_util.go b/pkg/rbd/rbd_util.go index 3e1b6f770..84d053a41 100644 --- a/pkg/rbd/rbd_util.go +++ b/pkg/rbd/rbd_util.go @@ -231,13 +231,13 @@ func getRBDVolumeOptions(volOptions map[string]string) (*rbdVolume, error) { rbdVol := &rbdVolume{} rbdVol.Pool, ok = volOptions["pool"] if !ok { - return nil, fmt.Errorf("Missing required parameter pool") + return nil, fmt.Errorf("missing required parameter pool") } rbdVol.Monitors, ok = volOptions["monitors"] if !ok { // if mons are not set in options, check if they are set in secret if rbdVol.MonValueFromSecret, ok = volOptions["monValueFromSecret"]; !ok { - return nil, fmt.Errorf("Either monitors or monValueFromSecret must be set") + return nil, fmt.Errorf("either monitors or monValueFromSecret must be set") } } rbdVol.ImageFormat, ok = volOptions["imageFormat"] @@ -283,13 +283,13 @@ func getRBDSnapshotOptions(snapOptions map[string]string) (*rbdSnapshot, error) rbdSnap := &rbdSnapshot{} rbdSnap.Pool, ok = snapOptions["pool"] if !ok { - return nil, fmt.Errorf("Missing required parameter pool") + return nil, fmt.Errorf("missing required parameter pool") } rbdSnap.Monitors, ok = snapOptions["monitors"] if !ok { // if mons are not set in options, check if they are set in secret if rbdSnap.MonValueFromSecret, ok = snapOptions["monValueFromSecret"]; !ok { - return nil, fmt.Errorf("Either monitors or monValueFromSecret must be set") + return nil, fmt.Errorf("either monitors or monValueFromSecret must be set") } } rbdSnap.AdminID, ok = snapOptions["adminid"]