From 25617929f0c311abd753f7ca5961ad34231034dc Mon Sep 17 00:00:00 2001 From: Humble Chirammal Date: Wed, 21 Oct 2020 12:30:55 +0530 Subject: [PATCH] rbd: use different variable instead of builtin `cap` function `cap` builtin function returns the capacity of a type. Its not good practice to use this builtin function for other variable names, removing it here Ref# https://golang.org/pkg/builtin/#cap Signed-off-by: Humble Chirammal --- internal/rbd/controllerserver.go | 10 +++++----- internal/util/validate.go | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/rbd/controllerserver.go b/internal/rbd/controllerserver.go index 5ef5bb617..e496b64d7 100644 --- a/internal/rbd/controllerserver.go +++ b/internal/rbd/controllerserver.go @@ -95,12 +95,12 @@ func (cs *ControllerServer) parseVolCreateRequest(ctx context.Context, req *csi. isMultiNode := false isBlock := false - for _, cap := range req.VolumeCapabilities { + for _, capability := range req.VolumeCapabilities { // RO modes need to be handled independently (ie right now even if access mode is RO, they'll be RW upon attach) - if cap.GetAccessMode().GetMode() == csi.VolumeCapability_AccessMode_MULTI_NODE_MULTI_WRITER { + if capability.GetAccessMode().GetMode() == csi.VolumeCapability_AccessMode_MULTI_NODE_MULTI_WRITER { isMultiNode = true } - if cap.GetBlock() != nil { + if capability.GetBlock() != nil { isBlock = true } } @@ -689,8 +689,8 @@ func (cs *ControllerServer) ValidateVolumeCapabilities(ctx context.Context, req return nil, status.Error(codes.InvalidArgument, "empty volume capabilities in request") } - for _, cap := range req.VolumeCapabilities { - if cap.GetAccessMode().GetMode() != csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER { + for _, capability := range req.VolumeCapabilities { + if capability.GetAccessMode().GetMode() != csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER { return &csi.ValidateVolumeCapabilitiesResponse{Message: ""}, nil } } diff --git a/internal/util/validate.go b/internal/util/validate.go index 81404249b..bc75bd685 100644 --- a/internal/util/validate.go +++ b/internal/util/validate.go @@ -82,8 +82,8 @@ func ValidateNodeUnpublishVolumeRequest(req *csi.NodeUnpublishVolumeRequest) err // CheckReadOnlyManyIsSupported checks the request is to create ReadOnlyMany // volume is from source as empty ReadOnlyMany is not supported. func CheckReadOnlyManyIsSupported(req *csi.CreateVolumeRequest) error { - for _, cap := range req.GetVolumeCapabilities() { - if m := cap.GetAccessMode().Mode; m == csi.VolumeCapability_AccessMode_MULTI_NODE_READER_ONLY || m == csi.VolumeCapability_AccessMode_SINGLE_NODE_READER_ONLY { + for _, capability := range req.GetVolumeCapabilities() { + if m := capability.GetAccessMode().Mode; m == csi.VolumeCapability_AccessMode_MULTI_NODE_READER_ONLY || m == csi.VolumeCapability_AccessMode_SINGLE_NODE_READER_ONLY { if req.GetVolumeContentSource() == nil { return status.Error(codes.InvalidArgument, "readOnly accessMode is supported only with content source") }