From 02e55f6d8d03f93fbb7b6040ed76617c798aa430 Mon Sep 17 00:00:00 2001 From: lukasmetzner Date: Mon, 11 Nov 2024 10:19:01 +0100 Subject: [PATCH] refactor: redefintion and shadowing of builtin id cap Update of golangci-lint to v1.62.0 discovered a redefinition of cap in our capability check. Furthermore, we are shadowing cap in certain places. --- internal/driver/controller.go | 8 ++++---- internal/driver/helper.go | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/driver/controller.go b/internal/driver/controller.go index 63967291..d7572145 100644 --- a/internal/driver/controller.go +++ b/internal/driver/controller.go @@ -49,8 +49,8 @@ func (s *ControllerService) CreateVolume(ctx context.Context, req *proto.CreateV } // Check if ALL volume capabilities are supported. - for i, cap := range req.VolumeCapabilities { - if !isCapabilitySupported(cap) { + for i, capability := range req.VolumeCapabilities { + if !isCapabilitySupported(capability) { return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("capability at index %d is not supported", i)) } } @@ -255,8 +255,8 @@ func (s *ControllerService) ValidateVolumeCapabilities(ctx context.Context, req } confirmed := true - for _, cap := range req.VolumeCapabilities { - if !isCapabilitySupported(cap) { + for _, capability := range req.VolumeCapabilities { + if !isCapabilitySupported(capability) { confirmed = false break } diff --git a/internal/driver/helper.go b/internal/driver/helper.go index 01a4c457..231a8ceb 100644 --- a/internal/driver/helper.go +++ b/internal/driver/helper.go @@ -45,11 +45,11 @@ func volumeSizeFromCapacityRange(cr *proto.CapacityRange) (int, int, bool) { return minSize, maxSize, true } -func isCapabilitySupported(cap *proto.VolumeCapability) bool { - if cap.AccessMode == nil { +func isCapabilitySupported(capability *proto.VolumeCapability) bool { + if capability.AccessMode == nil { return false } - switch cap.AccessMode.Mode { + switch capability.AccessMode.Mode { case proto.VolumeCapability_AccessMode_SINGLE_NODE_WRITER: return true case proto.VolumeCapability_AccessMode_SINGLE_NODE_MULTI_WRITER: