Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions internal/build/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"fmt"
"os"
"time"

"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob"
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/container"
Expand Down Expand Up @@ -61,7 +62,9 @@ func AzureBlobstoreUpload(path string, name string, config AzureBlobstoreConfig)
}
defer in.Close()

_, err = client.UploadFile(context.Background(), config.Container, name, in, nil)
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute)
defer cancel()
_, err = client.UploadFile(ctx, config.Container, name, in, nil)
return err
}

Expand All @@ -80,8 +83,10 @@ func AzureBlobstoreList(config AzureBlobstoreConfig) ([]*container.BlobItem, err
pager := client.NewListBlobsFlatPager(config.Container, nil)

var blobs []*container.BlobItem
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
defer cancel()
for pager.More() {
page, err := pager.NextPage(context.TODO())
page, err := pager.NextPage(ctx)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -111,9 +116,12 @@ func AzureBlobstoreDelete(config AzureBlobstoreConfig, blobs []*container.BlobIt
}
// Iterate over the blobs and delete them
for _, blob := range blobs {
if _, err := client.DeleteBlob(context.Background(), config.Container, *blob.Name, nil); err != nil {
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
if _, err := client.DeleteBlob(ctx, config.Container, *blob.Name, nil); err != nil {
cancel()
return err
}
cancel()
fmt.Printf("deleted %s (%s)\n", *blob.Name, blob.Properties.LastModified)
}
return nil
Expand Down