cleanup: use errors.As() in rbd.rbdStatus()

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:23:32 +02:00 committed by mergify[bot]
parent f93730dee7
commit 7126e92b4f

View File

@ -288,8 +288,9 @@ func rbdStatus(ctx context.Context, pOpts *rbdVolume, cr *util.Credentials) (boo
cmd, err := execCommand("rbd", args)
output = string(cmd)
if err, ok := err.(*exec.Error); ok {
if errors.Is(err.Err, exec.ErrNotFound) {
var ee *exec.Error
if errors.As(err, &ee) {
if errors.Is(ee, exec.ErrNotFound) {
klog.Errorf(util.Log(ctx, "rbd cmd not found"))
// fail fast if command not found
return false, output, err