cleanup: use errors.As() to compare errors in util/cephcmds

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 08:41:35 +02:00 committed by mergify[bot]
parent 8c4379862a
commit 57d0989593

View File

@ -19,6 +19,7 @@ package util
import (
"bytes"
"context"
"errors"
"fmt"
"io/ioutil"
"os"
@ -233,7 +234,8 @@ func CreateObject(ctx context.Context, monitors string, cr *Credentials, poolNam
ioctx, err := conn.GetIoctx(poolName)
if err != nil {
if _, ok := err.(ErrPoolNotFound); ok {
var epnf ErrPoolNotFound
if errors.As(err, &epnf) {
err = ErrObjectNotFound{poolName, err}
}
return err
@ -267,7 +269,8 @@ func RemoveObject(ctx context.Context, monitors string, cr *Credentials, poolNam
ioctx, err := conn.GetIoctx(poolName)
if err != nil {
if _, ok := err.(ErrPoolNotFound); ok {
var epnf ErrPoolNotFound
if errors.As(err, &epnf) {
err = ErrObjectNotFound{poolName, err}
}
return err