Skip to content

Commit 8d63deb

Browse files
committed
Using bloberror to handle error codes
1 parent 7c30843 commit 8d63deb

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

backends/azure/azure.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
1616
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
1717
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob"
18+
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/bloberror"
1819
"github.com/PowerDNS/go-tlsconfig"
1920
"github.com/PowerDNS/simpleblob"
2021
"github.com/go-logr/logr"
@@ -221,7 +222,7 @@ func New(ctx context.Context, opt Options) (*Backend, error) {
221222
})
222223

223224
if err != nil {
224-
if strings.Contains(err.Error(), "ContainerAlreadyExists") {
225+
if bloberror.HasCode(err, bloberror.ContainerAlreadyExists) {
225226
logrus.WithField("storage_type", "Azure").Infof("Container already exists: %s", opt.Container)
226227
} else {
227228
return nil, err
@@ -255,7 +256,7 @@ func (b *Backend) List(ctx context.Context, prefix string) (blobList simpleblob.
255256
var notFound bool
256257

257258
if err != nil {
258-
notFound = err.Error() == "BlobNotFound"
259+
notFound = bloberror.HasCode(err, bloberror.BlobNotFound)
259260
}
260261

261262
if err != nil && notFound {

0 commit comments

Comments
 (0)