cleanup: use errors.As() in cephfs.NodeStageVolume()

See-also: https://github.com/golang/go/wiki/ErrorValueFAQ#how-should-i-change-my-error-handling-code-to-work-with-the-new-features
Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
Niels de Vos 2020-06-25 10:35:19 +02:00 committed by mergify[bot]
parent c9d5bc8a08
commit 72c74f5f8a

View File

@ -18,6 +18,7 @@ package cephfs
import (
"context"
"errors"
"fmt"
"os"
"strings"
@ -88,14 +89,16 @@ func (ns *NodeServer) NodeStageVolume(ctx context.Context, req *csi.NodeStageVol
volOptions, _, err := newVolumeOptionsFromVolID(ctx, string(volID), req.GetVolumeContext(), req.GetSecrets())
if err != nil {
if _, ok := err.(ErrInvalidVolID); !ok {
var eivi ErrInvalidVolID
if !errors.As(err, &eivi) {
return nil, status.Error(codes.Internal, err.Error())
}
// check for pre-provisioned volumes (plugin versions > 1.0.0)
volOptions, _, err = newVolumeOptionsFromStaticVolume(string(volID), req.GetVolumeContext())
if err != nil {
if _, ok := err.(ErrNonStaticVolume); !ok {
var ensv ErrNonStaticVolume
if !errors.As(err, &ensv) {
return nil, status.Error(codes.Internal, err.Error())
}