Skip to content

Commit aad5a3b

Browse files
committed
Fixed error handlers
1 parent 84db079 commit aad5a3b

1 file changed

Lines changed: 15 additions & 16 deletions

File tree

pkg/skbn/abs.go

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -58,27 +58,35 @@ func getNewPipeline() (pipeline.Pipeline, error) {
5858

5959
pl := azblob.NewPipeline(credential, po)
6060

61-
return pl, err
61+
return pl, nil
6262
}
6363

6464
func getServiceURL(pl pipeline.Pipeline, accountName string) (azblob.ServiceURL, error) {
6565
URL, err := url.Parse(
6666
fmt.Sprintf("https://%s.blob.core.windows.net/", accountName))
6767

68+
if err != nil {
69+
return nil, err
70+
}
71+
6872
surl := azblob.NewServiceURL(*URL, pl)
69-
return surl, err
73+
return surl, nil
7074
}
7175

7276
func getContainerURL(pl pipeline.Pipeline, accountName string, containerName string) (azblob.ContainerURL, error) {
7377
URL, err := url.Parse(
7478
fmt.Sprintf("https://%s.blob.core.windows.net/%s", accountName, containerName))
7579

80+
if err != nil {
81+
return nil, err
82+
}
83+
7684
curl := azblob.NewContainerURL(*URL, pl)
77-
return curl, err
85+
return curl, nil
7886
}
7987

80-
func getBlobURL(curl azblob.ContainerURL, blob string) (azblob.BlockBlobURL, error) {
81-
return curl.NewBlockBlobURL(blob), err
88+
func getBlobURL(curl azblob.ContainerURL, blob string) azblob.BlockBlobURL {
89+
return curl.NewBlockBlobURL(blob)
8290
}
8391

8492
func listContainers(ctx context.Context, surl azblob.ServiceURL) ([]azblob.ContainerItem, error) {
@@ -177,12 +185,7 @@ func DownloadFromAbs(ctx context.Context, iClient interface{}, path string) ([]b
177185
return nil, err
178186
}
179187

180-
bu, err := getBlobURL(cu, p)
181-
182-
if err != nil {
183-
return nil, err
184-
}
185-
188+
bu := getBlobURL(cu, p)
186189
dr, err := bu.Download(ctx, 0, azblob.CountToEnd, azblob.BlobAccessConditions{}, false)
187190

188191
if err != nil {
@@ -221,11 +224,7 @@ func UploadToAbs(ctx context.Context, iClient interface{}, toPath, fromPath stri
221224
return err
222225
}
223226

224-
bu, err := getBlobURL(cu, p)
225-
226-
if err != nil {
227-
return err
228-
}
227+
bu := getBlobURL(cu, p)
229228

230229
_, err = azblob.UploadBufferToBlockBlob(ctx, buffer, bu, azblob.UploadToBlockBlobOptions{
231230
BlockSize: 4 * 1024 * 1024,

0 commit comments

Comments
 (0)