Skip to content
This repository has been archived by the owner on Mar 4, 2024. It is now read-only.

Commit

Permalink
fix errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Kralik committed Oct 12, 2023
1 parent b5324be commit 057b92e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions api/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,37 +246,37 @@ func azureAccess(ctx context.Context, l *zap.SugaredLogger, accountName, account
cred, err := azblob.NewSharedKeyCredential(accountName, accountKey)
if err != nil {
l.Error(err)
return errors.Join(errUserFacingMsg, errors.New("could not initialize Azure credentials"))
return errors.New("could not initialize Azure credentials")
}

client, err := azblob.NewClientWithSharedKeyCredential(fmt.Sprintf("https://%s.blob.core.windows.net/", url.PathEscape(accountName)), cred, nil)
if err != nil {
l.Error(err)
return errors.Join(errUserFacingMsg, errors.New("could not initialize Azure client"))
return errors.New("could not initialize Azure client")
}

pager := client.NewListBlobsFlatPager(containerName, nil)
if pager.More() {
if _, err := pager.NextPage(ctx); err != nil {
l.Error(err)
return errors.Join(errUserFacingMsg, errors.New("could not list blobs in Azure container"))
return errors.New("could not list blobs in Azure container")
}
}

blobName := "everest-test-blob"
if _, err = client.UploadBuffer(ctx, containerName, blobName, []byte{}, nil); err != nil {
l.Error(err)
return errors.Join(errUserFacingMsg, errors.New("could not write to Azure container"))
return errors.New("could not write to Azure container")
}

if _, err = client.DownloadBuffer(ctx, containerName, blobName, []byte{}, nil); err != nil {
l.Error(err)
return errors.Join(errUserFacingMsg, errors.New("could not read from Azure container"))
return errors.New("could not read from Azure container")
}

if _, err = client.DeleteBlob(ctx, containerName, blobName, nil); err != nil {
l.Error(err)
return errors.Join(errUserFacingMsg, errors.New("could not delete a blob from Azure container"))
return errors.New("could not delete a blob from Azure container")
}

return nil
Expand Down

0 comments on commit 057b92e

Please sign in to comment.