From 21ae81a499fe16dbb010401b2b378a1ea4b3cfb2 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Fri, 5 Apr 2024 10:18:11 +0200 Subject: [PATCH 1/4] `2023-11-03`: making the Response parsing consistent Now when deserializing the Response we're checking if `resp` and `resp.Response` are both != nil before trying to unmarshal. See https://github.com/hashicorp/terraform-provider-azurerm/issues/25521 for an example of where this manifests by being done inconsistently - as such doing this across the board means this'll take effect everywhere, plus be included in any new operations which are based on the existing one --- .../blob/accounts/get_service_properties.go | 2 +- .../blob/accounts/set_service_properties.go | 2 +- storage/2023-11-03/blob/blobs/append_block.go | 4 ++-- storage/2023-11-03/blob/blobs/copy.go | 4 ++-- storage/2023-11-03/blob/blobs/copy_abort.go | 2 +- storage/2023-11-03/blob/blobs/delete.go | 2 +- storage/2023-11-03/blob/blobs/delete_snapshot.go | 2 +- storage/2023-11-03/blob/blobs/delete_snapshots.go | 2 +- storage/2023-11-03/blob/blobs/get.go | 2 +- storage/2023-11-03/blob/blobs/get_block_list.go | 4 ++-- storage/2023-11-03/blob/blobs/get_page_ranges.go | 4 ++-- .../blob/blobs/incremental_copy_blob.go | 2 +- storage/2023-11-03/blob/blobs/lease_acquire.go | 2 +- storage/2023-11-03/blob/blobs/lease_break.go | 2 +- storage/2023-11-03/blob/blobs/lease_change.go | 2 +- storage/2023-11-03/blob/blobs/lease_release.go | 2 +- storage/2023-11-03/blob/blobs/lease_renew.go | 2 +- storage/2023-11-03/blob/blobs/metadata_set.go | 2 +- storage/2023-11-03/blob/blobs/properties_get.go | 4 ++-- storage/2023-11-03/blob/blobs/properties_set.go | 2 +- storage/2023-11-03/blob/blobs/put_append_blob.go | 2 +- storage/2023-11-03/blob/blobs/put_block.go | 2 +- storage/2023-11-03/blob/blobs/put_block_blob.go | 2 +- storage/2023-11-03/blob/blobs/put_block_list.go | 4 ++-- storage/2023-11-03/blob/blobs/put_block_url.go | 4 ++-- storage/2023-11-03/blob/blobs/put_page_blob.go | 2 +- storage/2023-11-03/blob/blobs/put_page_clear.go | 2 +- storage/2023-11-03/blob/blobs/put_page_update.go | 4 ++-- storage/2023-11-03/blob/blobs/set_tier.go | 2 +- storage/2023-11-03/blob/blobs/snapshot.go | 4 ++-- .../blob/blobs/snapshot_get_properties.go | 4 ++-- storage/2023-11-03/blob/blobs/undelete.go | 2 +- storage/2023-11-03/blob/containers/create.go | 2 +- storage/2023-11-03/blob/containers/delete.go | 2 +- .../2023-11-03/blob/containers/get_properties.go | 4 ++-- .../2023-11-03/blob/containers/lease_acquire.go | 4 ++-- storage/2023-11-03/blob/containers/lease_break.go | 4 ++-- .../2023-11-03/blob/containers/lease_change.go | 4 ++-- .../2023-11-03/blob/containers/lease_release.go | 2 +- storage/2023-11-03/blob/containers/lease_renew.go | 2 +- storage/2023-11-03/blob/containers/list_blobs.go | 2 +- storage/2023-11-03/blob/containers/set_acl.go | 2 +- .../2023-11-03/blob/containers/set_metadata.go | 2 +- .../datalakestore/filesystems/create.go | 2 +- .../datalakestore/filesystems/delete.go | 2 +- .../datalakestore/filesystems/properties_get.go | 4 ++-- .../datalakestore/filesystems/properties_set.go | 2 +- storage/2023-11-03/datalakestore/paths/create.go | 3 +-- storage/2023-11-03/datalakestore/paths/delete.go | 2 +- storage/2023-11-03/datalakestore/paths/helpers.go | 15 --------------- .../datalakestore/paths/properties_get.go | 4 ++-- .../datalakestore/paths/properties_set.go | 4 ++-- storage/2023-11-03/file/directories/create.go | 2 +- storage/2023-11-03/file/directories/delete.go | 2 +- storage/2023-11-03/file/directories/get.go | 4 ++-- .../2023-11-03/file/directories/metadata_get.go | 4 ++-- .../2023-11-03/file/directories/metadata_set.go | 2 +- storage/2023-11-03/file/files/copy.go | 4 ++-- storage/2023-11-03/file/files/copy_abort.go | 2 +- storage/2023-11-03/file/files/create.go | 2 +- storage/2023-11-03/file/files/delete.go | 2 +- storage/2023-11-03/file/files/metadata_get.go | 4 ++-- storage/2023-11-03/file/files/metadata_set.go | 2 +- storage/2023-11-03/file/files/properties_get.go | 4 ++-- storage/2023-11-03/file/files/properties_set.go | 2 +- storage/2023-11-03/file/files/range_clear.go | 2 +- storage/2023-11-03/file/files/range_get.go | 2 +- storage/2023-11-03/file/files/range_put.go | 2 +- storage/2023-11-03/file/files/ranges_list.go | 2 +- storage/2023-11-03/file/shares/acl_get.go | 2 +- storage/2023-11-03/file/shares/acl_set.go | 2 +- storage/2023-11-03/file/shares/create.go | 2 +- storage/2023-11-03/file/shares/delete.go | 2 +- storage/2023-11-03/file/shares/metadata_get.go | 4 ++-- storage/2023-11-03/file/shares/metadata_set.go | 2 +- storage/2023-11-03/file/shares/properties_get.go | 4 ++-- storage/2023-11-03/file/shares/properties_set.go | 2 +- storage/2023-11-03/file/shares/snapshot_create.go | 4 ++-- storage/2023-11-03/file/shares/snapshot_delete.go | 2 +- storage/2023-11-03/file/shares/snapshot_get.go | 4 ++-- storage/2023-11-03/queue/messages/delete.go | 2 +- storage/2023-11-03/queue/messages/get.go | 2 +- storage/2023-11-03/queue/messages/peek.go | 2 +- storage/2023-11-03/queue/messages/put.go | 2 +- storage/2023-11-03/queue/messages/update.go | 2 +- storage/2023-11-03/queue/queues/create.go | 2 +- storage/2023-11-03/queue/queues/delete.go | 2 +- storage/2023-11-03/queue/queues/metadata_get.go | 4 ++-- storage/2023-11-03/queue/queues/metadata_set.go | 2 +- storage/2023-11-03/queue/queues/properties_get.go | 2 +- storage/2023-11-03/queue/queues/properties_set.go | 2 +- storage/2023-11-03/table/entities/delete.go | 2 +- storage/2023-11-03/table/entities/get.go | 2 +- storage/2023-11-03/table/entities/insert.go | 2 +- .../2023-11-03/table/entities/insert_or_merge.go | 2 +- .../table/entities/insert_or_replace.go | 2 +- storage/2023-11-03/table/entities/query.go | 2 +- storage/2023-11-03/table/tables/acl_get.go | 2 +- storage/2023-11-03/table/tables/acl_set.go | 2 +- storage/2023-11-03/table/tables/create.go | 2 +- storage/2023-11-03/table/tables/delete.go | 2 +- storage/2023-11-03/table/tables/exists.go | 2 +- storage/2023-11-03/table/tables/query.go | 2 +- 103 files changed, 129 insertions(+), 145 deletions(-) delete mode 100644 storage/2023-11-03/datalakestore/paths/helpers.go diff --git a/storage/2023-11-03/blob/accounts/get_service_properties.go b/storage/2023-11-03/blob/accounts/get_service_properties.go index f230f16..668b127 100644 --- a/storage/2023-11-03/blob/accounts/get_service_properties.go +++ b/storage/2023-11-03/blob/accounts/get_service_properties.go @@ -36,7 +36,7 @@ func (c Client) GetServiceProperties(ctx context.Context, accountName string) (r var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response err = resp.Unmarshal(&result) diff --git a/storage/2023-11-03/blob/accounts/set_service_properties.go b/storage/2023-11-03/blob/accounts/set_service_properties.go index d881b04..7c6301e 100644 --- a/storage/2023-11-03/blob/accounts/set_service_properties.go +++ b/storage/2023-11-03/blob/accounts/set_service_properties.go @@ -40,7 +40,7 @@ func (c Client) SetServiceProperties(ctx context.Context, accountName string, in var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/blob/blobs/append_block.go b/storage/2023-11-03/blob/blobs/append_block.go index 87ddb60..26374e8 100644 --- a/storage/2023-11-03/blob/blobs/append_block.go +++ b/storage/2023-11-03/blob/blobs/append_block.go @@ -102,10 +102,10 @@ func (c Client) AppendBlock(ctx context.Context, containerName, blobName string, var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Response != nil && resp.Header != nil { + if resp.Header != nil { result.BlobAppendOffset = resp.Header.Get("x-ms-blob-append-offset") result.ContentMD5 = resp.Header.Get("Content-MD5") result.ETag = resp.Header.Get("ETag") diff --git a/storage/2023-11-03/blob/blobs/copy.go b/storage/2023-11-03/blob/blobs/copy.go index 696f7bd..50360cf 100644 --- a/storage/2023-11-03/blob/blobs/copy.go +++ b/storage/2023-11-03/blob/blobs/copy.go @@ -152,10 +152,10 @@ func (c Client) Copy(ctx context.Context, containerName, blobName string, input var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Response != nil && resp.Header != nil { + if resp.Header != nil { result.CopyID = resp.Header.Get("x-ms-copy-id") result.CopyStatus = resp.Header.Get("x-ms-copy-status") } diff --git a/storage/2023-11-03/blob/blobs/copy_abort.go b/storage/2023-11-03/blob/blobs/copy_abort.go index 5d9469a..b2190ea 100644 --- a/storage/2023-11-03/blob/blobs/copy_abort.go +++ b/storage/2023-11-03/blob/blobs/copy_abort.go @@ -64,7 +64,7 @@ func (c Client) AbortCopy(ctx context.Context, containerName, blobName string, i var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/blob/blobs/delete.go b/storage/2023-11-03/blob/blobs/delete.go index 80c1e43..68bb45d 100644 --- a/storage/2023-11-03/blob/blobs/delete.go +++ b/storage/2023-11-03/blob/blobs/delete.go @@ -57,7 +57,7 @@ func (c Client) Delete(ctx context.Context, containerName, blobName string, inpu var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/blob/blobs/delete_snapshot.go b/storage/2023-11-03/blob/blobs/delete_snapshot.go index e5cfa3c..d47153b 100644 --- a/storage/2023-11-03/blob/blobs/delete_snapshot.go +++ b/storage/2023-11-03/blob/blobs/delete_snapshot.go @@ -64,7 +64,7 @@ func (c Client) DeleteSnapshot(ctx context.Context, containerName, blobName stri var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/blob/blobs/delete_snapshots.go b/storage/2023-11-03/blob/blobs/delete_snapshots.go index dd0ce7b..f4f8899 100644 --- a/storage/2023-11-03/blob/blobs/delete_snapshots.go +++ b/storage/2023-11-03/blob/blobs/delete_snapshots.go @@ -56,7 +56,7 @@ func (c Client) DeleteSnapshots(ctx context.Context, containerName, blobName str var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/blob/blobs/get.go b/storage/2023-11-03/blob/blobs/get.go index 4ae212d..0e49f43 100644 --- a/storage/2023-11-03/blob/blobs/get.go +++ b/storage/2023-11-03/blob/blobs/get.go @@ -65,7 +65,7 @@ func (c Client) Get(ctx context.Context, containerName, blobName string, input G var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response if resp.Body != nil { diff --git a/storage/2023-11-03/blob/blobs/get_block_list.go b/storage/2023-11-03/blob/blobs/get_block_list.go index 73b4ea3..45a30a6 100644 --- a/storage/2023-11-03/blob/blobs/get_block_list.go +++ b/storage/2023-11-03/blob/blobs/get_block_list.go @@ -68,10 +68,10 @@ func (c Client) GetBlockList(ctx context.Context, containerName, blobName string var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Response != nil && resp.Header != nil { + if resp.Header != nil { result.ContentType = resp.Header.Get("Content-Type") result.ETag = resp.Header.Get("ETag") diff --git a/storage/2023-11-03/blob/blobs/get_page_ranges.go b/storage/2023-11-03/blob/blobs/get_page_ranges.go index 2150e6f..5341365 100644 --- a/storage/2023-11-03/blob/blobs/get_page_ranges.go +++ b/storage/2023-11-03/blob/blobs/get_page_ranges.go @@ -78,10 +78,10 @@ func (c Client) GetPageRanges(ctx context.Context, containerName, blobName strin var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Response != nil && resp.Header != nil { + if resp.Header != nil { result.ContentType = resp.Header.Get("Content-Type") result.ETag = resp.Header.Get("ETag") diff --git a/storage/2023-11-03/blob/blobs/incremental_copy_blob.go b/storage/2023-11-03/blob/blobs/incremental_copy_blob.go index 0423c0f..f3233d1 100644 --- a/storage/2023-11-03/blob/blobs/incremental_copy_blob.go +++ b/storage/2023-11-03/blob/blobs/incremental_copy_blob.go @@ -66,7 +66,7 @@ func (c Client) IncrementalCopyBlob(ctx context.Context, containerName, blobName var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/blob/blobs/lease_acquire.go b/storage/2023-11-03/blob/blobs/lease_acquire.go index 898e679..bf81cb3 100644 --- a/storage/2023-11-03/blob/blobs/lease_acquire.go +++ b/storage/2023-11-03/blob/blobs/lease_acquire.go @@ -80,7 +80,7 @@ func (c Client) AcquireLease(ctx context.Context, containerName, blobName string var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response if resp.Response != nil && resp.Header != nil { diff --git a/storage/2023-11-03/blob/blobs/lease_break.go b/storage/2023-11-03/blob/blobs/lease_break.go index 74e6891..393e329 100644 --- a/storage/2023-11-03/blob/blobs/lease_break.go +++ b/storage/2023-11-03/blob/blobs/lease_break.go @@ -74,7 +74,7 @@ func (c Client) BreakLease(ctx context.Context, containerName, blobName string, var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/blob/blobs/lease_change.go b/storage/2023-11-03/blob/blobs/lease_change.go index 9f9082d..46ee080 100644 --- a/storage/2023-11-03/blob/blobs/lease_change.go +++ b/storage/2023-11-03/blob/blobs/lease_change.go @@ -67,7 +67,7 @@ func (c Client) ChangeLease(ctx context.Context, containerName, blobName string, var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response if resp.Response != nil && resp.Header != nil { diff --git a/storage/2023-11-03/blob/blobs/lease_release.go b/storage/2023-11-03/blob/blobs/lease_release.go index 2101828..bf6b91e 100644 --- a/storage/2023-11-03/blob/blobs/lease_release.go +++ b/storage/2023-11-03/blob/blobs/lease_release.go @@ -59,7 +59,7 @@ func (c Client) ReleaseLease(ctx context.Context, containerName, blobName string var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/blob/blobs/lease_renew.go b/storage/2023-11-03/blob/blobs/lease_renew.go index e43a12d..4d60528 100644 --- a/storage/2023-11-03/blob/blobs/lease_renew.go +++ b/storage/2023-11-03/blob/blobs/lease_renew.go @@ -58,7 +58,7 @@ func (c Client) RenewLease(ctx context.Context, containerName, blobName string, var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/blob/blobs/metadata_set.go b/storage/2023-11-03/blob/blobs/metadata_set.go index ce6c047..a9f9c00 100644 --- a/storage/2023-11-03/blob/blobs/metadata_set.go +++ b/storage/2023-11-03/blob/blobs/metadata_set.go @@ -65,7 +65,7 @@ func (c Client) SetMetaData(ctx context.Context, containerName, blobName string, var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/blob/blobs/properties_get.go b/storage/2023-11-03/blob/blobs/properties_get.go index 45156b2..6ae254d 100644 --- a/storage/2023-11-03/blob/blobs/properties_get.go +++ b/storage/2023-11-03/blob/blobs/properties_get.go @@ -197,10 +197,10 @@ func (c Client) GetProperties(ctx context.Context, containerName, blobName strin var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Response != nil && resp.Header != nil { + if resp.Header != nil { result.AccessTier = AccessTier(resp.Header.Get("x-ms-access-tier")) result.AccessTierChangeTime = resp.Header.Get("x-ms-access-tier-change-time") result.ArchiveStatus = ArchiveStatus(resp.Header.Get("x-ms-archive-status")) diff --git a/storage/2023-11-03/blob/blobs/properties_set.go b/storage/2023-11-03/blob/blobs/properties_set.go index 73b417f..2bb35c7 100644 --- a/storage/2023-11-03/blob/blobs/properties_set.go +++ b/storage/2023-11-03/blob/blobs/properties_set.go @@ -64,7 +64,7 @@ func (c Client) SetProperties(ctx context.Context, containerName, blobName strin var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/blob/blobs/put_append_blob.go b/storage/2023-11-03/blob/blobs/put_append_blob.go index 8cc5300..390d7c3 100644 --- a/storage/2023-11-03/blob/blobs/put_append_blob.go +++ b/storage/2023-11-03/blob/blobs/put_append_blob.go @@ -69,7 +69,7 @@ func (c Client) PutAppendBlob(ctx context.Context, containerName, blobName strin var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/blob/blobs/put_block.go b/storage/2023-11-03/blob/blobs/put_block.go index f261dde..eeb6b59 100644 --- a/storage/2023-11-03/blob/blobs/put_block.go +++ b/storage/2023-11-03/blob/blobs/put_block.go @@ -75,7 +75,7 @@ func (c Client) PutBlock(ctx context.Context, containerName, blobName string, in var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/blob/blobs/put_block_blob.go b/storage/2023-11-03/blob/blobs/put_block_blob.go index ad8cc81..8ff955e 100644 --- a/storage/2023-11-03/blob/blobs/put_block_blob.go +++ b/storage/2023-11-03/blob/blobs/put_block_blob.go @@ -87,7 +87,7 @@ func (c Client) PutBlockBlob(ctx context.Context, containerName, blobName string var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/blob/blobs/put_block_list.go b/storage/2023-11-03/blob/blobs/put_block_list.go index e55a5cc..cf04af0 100644 --- a/storage/2023-11-03/blob/blobs/put_block_list.go +++ b/storage/2023-11-03/blob/blobs/put_block_list.go @@ -86,10 +86,10 @@ func (c Client) PutBlockList(ctx context.Context, containerName, blobName string var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Response != nil && resp.Header != nil { + if resp.Header != nil { result.ContentMD5 = resp.Header.Get("Content-MD5") result.ETag = resp.Header.Get("ETag") result.LastModified = resp.Header.Get("Last-Modified") diff --git a/storage/2023-11-03/blob/blobs/put_block_url.go b/storage/2023-11-03/blob/blobs/put_block_url.go index c509f07..2b683d7 100644 --- a/storage/2023-11-03/blob/blobs/put_block_url.go +++ b/storage/2023-11-03/blob/blobs/put_block_url.go @@ -71,10 +71,10 @@ func (c Client) PutBlockFromURL(ctx context.Context, containerName, blobName str var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Response != nil && resp.Header != nil { + if resp.Header != nil { result.ContentMD5 = resp.Header.Get("Content-MD5") } } diff --git a/storage/2023-11-03/blob/blobs/put_page_blob.go b/storage/2023-11-03/blob/blobs/put_page_blob.go index 74bfc6b..1c7c839 100644 --- a/storage/2023-11-03/blob/blobs/put_page_blob.go +++ b/storage/2023-11-03/blob/blobs/put_page_blob.go @@ -74,7 +74,7 @@ func (c Client) PutPageBlob(ctx context.Context, containerName, blobName string, var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/blob/blobs/put_page_clear.go b/storage/2023-11-03/blob/blobs/put_page_clear.go index 45e0499..04e70e3 100644 --- a/storage/2023-11-03/blob/blobs/put_page_clear.go +++ b/storage/2023-11-03/blob/blobs/put_page_clear.go @@ -68,7 +68,7 @@ func (c Client) PutPageClear(ctx context.Context, containerName, blobName string var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/blob/blobs/put_page_update.go b/storage/2023-11-03/blob/blobs/put_page_update.go index 67b6c9e..3294d46 100644 --- a/storage/2023-11-03/blob/blobs/put_page_update.go +++ b/storage/2023-11-03/blob/blobs/put_page_update.go @@ -94,10 +94,10 @@ func (c Client) PutPageUpdate(ctx context.Context, containerName, blobName strin var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Response != nil && resp.Header != nil { + if resp.Header != nil { result.BlobSequenceNumber = resp.Header.Get("x-ms-blob-sequence-number") result.ContentMD5 = resp.Header.Get("Content-MD5") result.LastModified = resp.Header.Get("Last-Modified") diff --git a/storage/2023-11-03/blob/blobs/set_tier.go b/storage/2023-11-03/blob/blobs/set_tier.go index 66b9d64..34672a8 100644 --- a/storage/2023-11-03/blob/blobs/set_tier.go +++ b/storage/2023-11-03/blob/blobs/set_tier.go @@ -55,7 +55,7 @@ func (c Client) SetTier(ctx context.Context, containerName, blobName string, inp var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/blob/blobs/snapshot.go b/storage/2023-11-03/blob/blobs/snapshot.go index 582161e..18ddcd2 100644 --- a/storage/2023-11-03/blob/blobs/snapshot.go +++ b/storage/2023-11-03/blob/blobs/snapshot.go @@ -96,10 +96,10 @@ func (c Client) Snapshot(ctx context.Context, containerName, blobName string, in var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Response != nil && resp.Header != nil { + if resp.Header != nil { result.ETag = resp.Header.Get("ETag") result.SnapshotDateTime = resp.Header.Get("x-ms-snapshot") } diff --git a/storage/2023-11-03/blob/blobs/snapshot_get_properties.go b/storage/2023-11-03/blob/blobs/snapshot_get_properties.go index dc8059a..59f3607 100644 --- a/storage/2023-11-03/blob/blobs/snapshot_get_properties.go +++ b/storage/2023-11-03/blob/blobs/snapshot_get_properties.go @@ -63,10 +63,10 @@ func (c Client) GetSnapshotProperties(ctx context.Context, containerName, blobNa var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Response != nil && resp.Header != nil { + if resp.Header != nil { result.AccessTier = AccessTier(resp.Header.Get("x-ms-access-tier")) result.AccessTierChangeTime = resp.Header.Get("x-ms-access-tier-change-time") result.ArchiveStatus = ArchiveStatus(resp.Header.Get("x-ms-archive-status")) diff --git a/storage/2023-11-03/blob/blobs/undelete.go b/storage/2023-11-03/blob/blobs/undelete.go index 149971f..ed5a7f9 100644 --- a/storage/2023-11-03/blob/blobs/undelete.go +++ b/storage/2023-11-03/blob/blobs/undelete.go @@ -48,7 +48,7 @@ func (c Client) Undelete(ctx context.Context, containerName, blobName string) (r var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/blob/containers/create.go b/storage/2023-11-03/blob/containers/create.go index f47c4cf..92b7c9f 100644 --- a/storage/2023-11-03/blob/containers/create.go +++ b/storage/2023-11-03/blob/containers/create.go @@ -90,7 +90,7 @@ func (c Client) Create(ctx context.Context, containerName string, input CreateIn var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/blob/containers/delete.go b/storage/2023-11-03/blob/containers/delete.go index d654e4a..d3d6eca 100644 --- a/storage/2023-11-03/blob/containers/delete.go +++ b/storage/2023-11-03/blob/containers/delete.go @@ -38,7 +38,7 @@ func (c Client) Delete(ctx context.Context, containerName string) (result Delete var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/blob/containers/get_properties.go b/storage/2023-11-03/blob/containers/get_properties.go index 7989729..dab47b4 100644 --- a/storage/2023-11-03/blob/containers/get_properties.go +++ b/storage/2023-11-03/blob/containers/get_properties.go @@ -47,10 +47,10 @@ func (c Client) GetProperties(ctx context.Context, containerName string, input G var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Response != nil && resp.Header != nil { + if resp.Header != nil { result.DefaultEncryptionScope = resp.Header.Get("x-ms-default-encryption-scope") result.LeaseStatus = LeaseStatus(resp.Header.Get("x-ms-lease-status")) result.LeaseState = LeaseState(resp.Header.Get("x-ms-lease-state")) diff --git a/storage/2023-11-03/blob/containers/lease_acquire.go b/storage/2023-11-03/blob/containers/lease_acquire.go index 9b86809..1a2fc9d 100644 --- a/storage/2023-11-03/blob/containers/lease_acquire.go +++ b/storage/2023-11-03/blob/containers/lease_acquire.go @@ -57,10 +57,10 @@ func (c Client) AcquireLease(ctx context.Context, containerName string, input Ac var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Response != nil && resp.Header != nil { + if resp.Header != nil { result.LeaseID = resp.Header.Get("x-ms-lease-id") } } diff --git a/storage/2023-11-03/blob/containers/lease_break.go b/storage/2023-11-03/blob/containers/lease_break.go index 3fe413a..db91393 100644 --- a/storage/2023-11-03/blob/containers/lease_break.go +++ b/storage/2023-11-03/blob/containers/lease_break.go @@ -64,10 +64,10 @@ func (c Client) BreakLease(ctx context.Context, containerName string, input Brea var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Response != nil && resp.Header != nil { + if resp.Header != nil { if leaseTimeRaw := resp.Header.Get("x-ms-lease-time"); leaseTimeRaw != "" { if leaseTime, err := strconv.Atoi(leaseTimeRaw); err == nil { result.LeaseTime = leaseTime diff --git a/storage/2023-11-03/blob/containers/lease_change.go b/storage/2023-11-03/blob/containers/lease_change.go index f545c65..fe0ae9b 100644 --- a/storage/2023-11-03/blob/containers/lease_change.go +++ b/storage/2023-11-03/blob/containers/lease_change.go @@ -59,10 +59,10 @@ func (c Client) ChangeLease(ctx context.Context, containerName string, input Cha var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Response != nil && resp.Header != nil { + if resp.Header != nil { result.LeaseID = resp.Header.Get("x-ms-lease-id") } } diff --git a/storage/2023-11-03/blob/containers/lease_release.go b/storage/2023-11-03/blob/containers/lease_release.go index cdff4e2..e9bb253 100644 --- a/storage/2023-11-03/blob/containers/lease_release.go +++ b/storage/2023-11-03/blob/containers/lease_release.go @@ -48,7 +48,7 @@ func (c Client) ReleaseLease(ctx context.Context, containerName string, input Re var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/blob/containers/lease_renew.go b/storage/2023-11-03/blob/containers/lease_renew.go index 38c9486..45e8308 100644 --- a/storage/2023-11-03/blob/containers/lease_renew.go +++ b/storage/2023-11-03/blob/containers/lease_renew.go @@ -48,7 +48,7 @@ func (c Client) RenewLease(ctx context.Context, containerName string, input Rene var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/blob/containers/list_blobs.go b/storage/2023-11-03/blob/containers/list_blobs.go index 86ddc7c..009b77e 100644 --- a/storage/2023-11-03/blob/containers/list_blobs.go +++ b/storage/2023-11-03/blob/containers/list_blobs.go @@ -114,7 +114,7 @@ func (c Client) ListBlobs(ctx context.Context, containerName string, input ListB var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response err = resp.Unmarshal(&result) diff --git a/storage/2023-11-03/blob/containers/set_acl.go b/storage/2023-11-03/blob/containers/set_acl.go index 280ad4e..f933c54 100644 --- a/storage/2023-11-03/blob/containers/set_acl.go +++ b/storage/2023-11-03/blob/containers/set_acl.go @@ -47,7 +47,7 @@ func (c Client) SetAccessControl(ctx context.Context, containerName string, inpu var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/blob/containers/set_metadata.go b/storage/2023-11-03/blob/containers/set_metadata.go index 3f8bb07..6d43250 100644 --- a/storage/2023-11-03/blob/containers/set_metadata.go +++ b/storage/2023-11-03/blob/containers/set_metadata.go @@ -51,7 +51,7 @@ func (c Client) SetMetaData(ctx context.Context, containerName string, input Set var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/datalakestore/filesystems/create.go b/storage/2023-11-03/datalakestore/filesystems/create.go index 5bf1b66..9472e1e 100644 --- a/storage/2023-11-03/datalakestore/filesystems/create.go +++ b/storage/2023-11-03/datalakestore/filesystems/create.go @@ -49,7 +49,7 @@ func (c Client) Create(ctx context.Context, fileSystemName string, input CreateI var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/datalakestore/filesystems/delete.go b/storage/2023-11-03/datalakestore/filesystems/delete.go index 6900f28..980f83d 100644 --- a/storage/2023-11-03/datalakestore/filesystems/delete.go +++ b/storage/2023-11-03/datalakestore/filesystems/delete.go @@ -37,7 +37,7 @@ func (c Client) Delete(ctx context.Context, fileSystemName string) (result Delet var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/datalakestore/filesystems/properties_get.go b/storage/2023-11-03/datalakestore/filesystems/properties_get.go index 449aafa..d5d424e 100644 --- a/storage/2023-11-03/datalakestore/filesystems/properties_get.go +++ b/storage/2023-11-03/datalakestore/filesystems/properties_get.go @@ -47,10 +47,10 @@ func (c Client) GetProperties(ctx context.Context, fileSystemName string) (resul var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Response != nil && resp.Header != nil { + if resp.Header != nil { propertiesRaw := resp.Header.Get("x-ms-properties") var properties *map[string]string properties, err = parseProperties(propertiesRaw) diff --git a/storage/2023-11-03/datalakestore/filesystems/properties_set.go b/storage/2023-11-03/datalakestore/filesystems/properties_set.go index 775807a..25455d6 100644 --- a/storage/2023-11-03/datalakestore/filesystems/properties_set.go +++ b/storage/2023-11-03/datalakestore/filesystems/properties_set.go @@ -59,7 +59,7 @@ func (c Client) SetProperties(ctx context.Context, fileSystemName string, input var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/datalakestore/paths/create.go b/storage/2023-11-03/datalakestore/paths/create.go index 8db9b66..1b16c9b 100644 --- a/storage/2023-11-03/datalakestore/paths/create.go +++ b/storage/2023-11-03/datalakestore/paths/create.go @@ -43,7 +43,6 @@ func (c Client) Create(ctx context.Context, fileSystemName string, path string, } req, err := c.Client.NewRequest(ctx, opts) - if err != nil { err = fmt.Errorf("building request: %+v", err) return result, err @@ -51,7 +50,7 @@ func (c Client) Create(ctx context.Context, fileSystemName string, path string, var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/datalakestore/paths/delete.go b/storage/2023-11-03/datalakestore/paths/delete.go index 990be51..8695a53 100644 --- a/storage/2023-11-03/datalakestore/paths/delete.go +++ b/storage/2023-11-03/datalakestore/paths/delete.go @@ -36,7 +36,7 @@ func (c Client) Delete(ctx context.Context, fileSystemName string, path string) var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/datalakestore/paths/helpers.go b/storage/2023-11-03/datalakestore/paths/helpers.go deleted file mode 100644 index 08d893c..0000000 --- a/storage/2023-11-03/datalakestore/paths/helpers.go +++ /dev/null @@ -1,15 +0,0 @@ -package paths - -import ( - "fmt" -) - -func parsePathResource(input string) (PathResource, error) { - switch input { - case "file": - return PathResourceFile, nil - case "directory": - return PathResourceDirectory, nil - } - return "", fmt.Errorf("unhandled path resource type %q", input) -} diff --git a/storage/2023-11-03/datalakestore/paths/properties_get.go b/storage/2023-11-03/datalakestore/paths/properties_get.go index f2ffa31..9f620e8 100644 --- a/storage/2023-11-03/datalakestore/paths/properties_get.go +++ b/storage/2023-11-03/datalakestore/paths/properties_get.go @@ -62,10 +62,10 @@ func (c Client) GetProperties(ctx context.Context, fileSystemName string, path s var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Response != nil && resp.Header != nil { + if resp.Header != nil { result.ResourceType = PathResource(resp.Header.Get("x-ms-resource-type")) result.ETag = resp.Header.Get("ETag") diff --git a/storage/2023-11-03/datalakestore/paths/properties_set.go b/storage/2023-11-03/datalakestore/paths/properties_set.go index 826e0ef..fcb7707 100644 --- a/storage/2023-11-03/datalakestore/paths/properties_set.go +++ b/storage/2023-11-03/datalakestore/paths/properties_set.go @@ -27,7 +27,7 @@ type SetPropertiesResponse struct { HttpResponse *http.Response } -// SetProperties sets the access control properties for a Data Lake Store Gen2 Path within a Storage Account File System +// SetAccessControl sets the access control properties for a Data Lake Store Gen2 Path within a Storage Account File System func (c Client) SetAccessControl(ctx context.Context, fileSystemName string, path string, input SetAccessControlInput) (result SetPropertiesResponse, err error) { if fileSystemName == "" { err = fmt.Errorf("`fileSystemName` cannot be an empty string") @@ -55,7 +55,7 @@ func (c Client) SetAccessControl(ctx context.Context, fileSystemName string, pat var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/file/directories/create.go b/storage/2023-11-03/file/directories/create.go index fdca3cf..a1eb3bb 100644 --- a/storage/2023-11-03/file/directories/create.go +++ b/storage/2023-11-03/file/directories/create.go @@ -74,7 +74,7 @@ func (c Client) Create(ctx context.Context, shareName, path string, input Create var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/file/directories/delete.go b/storage/2023-11-03/file/directories/delete.go index eeae2c2..7c1a90f 100644 --- a/storage/2023-11-03/file/directories/delete.go +++ b/storage/2023-11-03/file/directories/delete.go @@ -80,7 +80,7 @@ func (c Client) Delete(ctx context.Context, shareName, path string) (result Dele var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/file/directories/get.go b/storage/2023-11-03/file/directories/get.go index 1985d7d..b49444a 100644 --- a/storage/2023-11-03/file/directories/get.go +++ b/storage/2023-11-03/file/directories/get.go @@ -57,10 +57,10 @@ func (c Client) Get(ctx context.Context, shareName, path string) (result GetResp var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Response != nil && resp.Header != nil { + if resp.Header != nil { result.DirectoryMetaDataEncrypted = strings.EqualFold(resp.Header.Get("x-ms-server-encrypted"), "true") result.MetaData = metadata.ParseFromHeaders(resp.Header) } diff --git a/storage/2023-11-03/file/directories/metadata_get.go b/storage/2023-11-03/file/directories/metadata_get.go index 4568112..aa6e0ac 100644 --- a/storage/2023-11-03/file/directories/metadata_get.go +++ b/storage/2023-11-03/file/directories/metadata_get.go @@ -52,10 +52,10 @@ func (c Client) GetMetaData(ctx context.Context, shareName, path string) (result var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Response != nil && resp.Header != nil { + if resp.Header != nil { result.MetaData = metadata.ParseFromHeaders(resp.Header) } } diff --git a/storage/2023-11-03/file/directories/metadata_set.go b/storage/2023-11-03/file/directories/metadata_set.go index 8aa9097..ca9e070 100644 --- a/storage/2023-11-03/file/directories/metadata_set.go +++ b/storage/2023-11-03/file/directories/metadata_set.go @@ -62,7 +62,7 @@ func (c Client) SetMetaData(ctx context.Context, shareName, path string, input S var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/file/files/copy.go b/storage/2023-11-03/file/files/copy.go index 7f13ce2..2562443 100644 --- a/storage/2023-11-03/file/files/copy.go +++ b/storage/2023-11-03/file/files/copy.go @@ -86,10 +86,10 @@ func (c Client) Copy(ctx context.Context, shareName, path, fileName string, inpu var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Response != nil && resp.Header != nil { + if resp.Header != nil { result.CopyID = resp.Header.Get("x-ms-copy-id") result.CopySuccess = resp.Header.Get("x-ms-copy-status") } diff --git a/storage/2023-11-03/file/files/copy_abort.go b/storage/2023-11-03/file/files/copy_abort.go index 191929b..5dcdfb3 100644 --- a/storage/2023-11-03/file/files/copy_abort.go +++ b/storage/2023-11-03/file/files/copy_abort.go @@ -65,7 +65,7 @@ func (c Client) AbortCopy(ctx context.Context, shareName, path, fileName string, var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/file/files/create.go b/storage/2023-11-03/file/files/create.go index 5fb8e97..0fc6152 100644 --- a/storage/2023-11-03/file/files/create.go +++ b/storage/2023-11-03/file/files/create.go @@ -100,7 +100,7 @@ func (c Client) Create(ctx context.Context, shareName, path, fileName string, in var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/file/files/delete.go b/storage/2023-11-03/file/files/delete.go index 90c7737..69a492a 100644 --- a/storage/2023-11-03/file/files/delete.go +++ b/storage/2023-11-03/file/files/delete.go @@ -53,7 +53,7 @@ func (c Client) Delete(ctx context.Context, shareName, path, fileName string) (r var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/file/files/metadata_get.go b/storage/2023-11-03/file/files/metadata_get.go index 0a9778b..ca88c3c 100644 --- a/storage/2023-11-03/file/files/metadata_get.go +++ b/storage/2023-11-03/file/files/metadata_get.go @@ -56,10 +56,10 @@ func (c Client) GetMetaData(ctx context.Context, shareName, path, fileName strin var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Response != nil && resp.Header != nil { + if resp.Header != nil { result.MetaData = metadata.ParseFromHeaders(resp.Header) } } diff --git a/storage/2023-11-03/file/files/metadata_set.go b/storage/2023-11-03/file/files/metadata_set.go index e1ba9d0..91aa6ee 100644 --- a/storage/2023-11-03/file/files/metadata_set.go +++ b/storage/2023-11-03/file/files/metadata_set.go @@ -65,7 +65,7 @@ func (c Client) SetMetaData(ctx context.Context, shareName, path, fileName strin var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/file/files/properties_get.go b/storage/2023-11-03/file/files/properties_get.go index 129ad24..fa5fbc3 100644 --- a/storage/2023-11-03/file/files/properties_get.go +++ b/storage/2023-11-03/file/files/properties_get.go @@ -71,10 +71,10 @@ func (c Client) GetProperties(ctx context.Context, shareName, path, fileName str var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Response != nil && resp.Header != nil { + if resp.Header != nil { result.CacheControl = resp.Header.Get("Cache-Control") result.ContentDisposition = resp.Header.Get("Content-Disposition") result.ContentEncoding = resp.Header.Get("Content-Encoding") diff --git a/storage/2023-11-03/file/files/properties_set.go b/storage/2023-11-03/file/files/properties_set.go index 18ecd83..73fa1b0 100644 --- a/storage/2023-11-03/file/files/properties_set.go +++ b/storage/2023-11-03/file/files/properties_set.go @@ -112,7 +112,7 @@ func (c Client) SetProperties(ctx context.Context, shareName, path, fileName str var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/file/files/range_clear.go b/storage/2023-11-03/file/files/range_clear.go index 0a1e814..bc276b4 100644 --- a/storage/2023-11-03/file/files/range_clear.go +++ b/storage/2023-11-03/file/files/range_clear.go @@ -71,7 +71,7 @@ func (c Client) ClearByteRange(ctx context.Context, shareName, path, fileName st var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/file/files/range_get.go b/storage/2023-11-03/file/files/range_get.go index f8b40b8..9b2dec4 100644 --- a/storage/2023-11-03/file/files/range_get.go +++ b/storage/2023-11-03/file/files/range_get.go @@ -82,7 +82,7 @@ func (c Client) GetByteRange(ctx context.Context, shareName, path, fileName stri var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.Contents = &[]byte{} result.HttpResponse = resp.Response diff --git a/storage/2023-11-03/file/files/range_put.go b/storage/2023-11-03/file/files/range_put.go index c799ffd..358d28d 100644 --- a/storage/2023-11-03/file/files/range_put.go +++ b/storage/2023-11-03/file/files/range_put.go @@ -90,7 +90,7 @@ func (c Client) PutByteRange(ctx context.Context, shareName, path, fileName stri var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/file/files/ranges_list.go b/storage/2023-11-03/file/files/ranges_list.go index 0b89e6c..d6b1df4 100644 --- a/storage/2023-11-03/file/files/ranges_list.go +++ b/storage/2023-11-03/file/files/ranges_list.go @@ -65,7 +65,7 @@ func (c Client) ListRanges(ctx context.Context, shareName, path, fileName string var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response err = resp.Unmarshal(&result) diff --git a/storage/2023-11-03/file/shares/acl_get.go b/storage/2023-11-03/file/shares/acl_get.go index 8add483..2c9c5ea 100644 --- a/storage/2023-11-03/file/shares/acl_get.go +++ b/storage/2023-11-03/file/shares/acl_get.go @@ -45,7 +45,7 @@ func (c Client) GetACL(ctx context.Context, shareName string) (result GetACLResu var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response err = resp.Unmarshal(&result) diff --git a/storage/2023-11-03/file/shares/acl_set.go b/storage/2023-11-03/file/shares/acl_set.go index 216d714..0136350 100644 --- a/storage/2023-11-03/file/shares/acl_set.go +++ b/storage/2023-11-03/file/shares/acl_set.go @@ -64,7 +64,7 @@ func (c Client) SetACL(ctx context.Context, shareName string, input SetAclInput) var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/file/shares/create.go b/storage/2023-11-03/file/shares/create.go index 46e8757..11c39e6 100644 --- a/storage/2023-11-03/file/shares/create.go +++ b/storage/2023-11-03/file/shares/create.go @@ -110,7 +110,7 @@ func (c Client) Create(ctx context.Context, shareName string, input CreateInput) var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/file/shares/delete.go b/storage/2023-11-03/file/shares/delete.go index 84667f6..28ce7d4 100644 --- a/storage/2023-11-03/file/shares/delete.go +++ b/storage/2023-11-03/file/shares/delete.go @@ -49,7 +49,7 @@ func (c Client) Delete(ctx context.Context, shareName string, input DeleteInput) var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/file/shares/metadata_get.go b/storage/2023-11-03/file/shares/metadata_get.go index c04681d..ae34b3d 100644 --- a/storage/2023-11-03/file/shares/metadata_get.go +++ b/storage/2023-11-03/file/shares/metadata_get.go @@ -44,10 +44,10 @@ func (c Client) GetMetaData(ctx context.Context, shareName string) (result GetMe var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Response != nil && resp.Header != nil { + if resp.Header != nil { result.MetaData = metadata.ParseFromHeaders(resp.Header) } } diff --git a/storage/2023-11-03/file/shares/metadata_set.go b/storage/2023-11-03/file/shares/metadata_set.go index 55bf1d4..33c6efa 100644 --- a/storage/2023-11-03/file/shares/metadata_set.go +++ b/storage/2023-11-03/file/shares/metadata_set.go @@ -57,7 +57,7 @@ func (c Client) SetMetaData(ctx context.Context, shareName string, input SetMeta var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/file/shares/properties_get.go b/storage/2023-11-03/file/shares/properties_get.go index 835c373..d33b471 100644 --- a/storage/2023-11-03/file/shares/properties_get.go +++ b/storage/2023-11-03/file/shares/properties_get.go @@ -50,10 +50,10 @@ func (c Client) GetProperties(ctx context.Context, shareName string) (result Get var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Response != nil && resp.Header != nil { + if resp.Header != nil { result.MetaData = metadata.ParseFromHeaders(resp.Header) quotaRaw := resp.Header.Get("x-ms-share-quota") diff --git a/storage/2023-11-03/file/shares/properties_set.go b/storage/2023-11-03/file/shares/properties_set.go index f80df4f..2c444c4 100644 --- a/storage/2023-11-03/file/shares/properties_set.go +++ b/storage/2023-11-03/file/shares/properties_set.go @@ -55,7 +55,7 @@ func (c Client) SetProperties(ctx context.Context, shareName string, properties var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/file/shares/snapshot_create.go b/storage/2023-11-03/file/shares/snapshot_create.go index cb278bf..6de6e43 100644 --- a/storage/2023-11-03/file/shares/snapshot_create.go +++ b/storage/2023-11-03/file/shares/snapshot_create.go @@ -64,10 +64,10 @@ func (c Client) CreateSnapshot(ctx context.Context, shareName string, input Crea var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Response != nil && resp.Header != nil { + if resp.Header != nil { result.SnapshotDateTime = resp.Header.Get("x-ms-snapshot") } } diff --git a/storage/2023-11-03/file/shares/snapshot_delete.go b/storage/2023-11-03/file/shares/snapshot_delete.go index 64dd532..dcd590d 100644 --- a/storage/2023-11-03/file/shares/snapshot_delete.go +++ b/storage/2023-11-03/file/shares/snapshot_delete.go @@ -49,7 +49,7 @@ func (c Client) DeleteSnapshot(ctx context.Context, accountName, shareName strin var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/file/shares/snapshot_get.go b/storage/2023-11-03/file/shares/snapshot_get.go index 99d28a8..cde1d2f 100644 --- a/storage/2023-11-03/file/shares/snapshot_get.go +++ b/storage/2023-11-03/file/shares/snapshot_get.go @@ -58,10 +58,10 @@ func (c Client) GetSnapshot(ctx context.Context, shareName string, input GetSnap var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Response != nil && resp.Header != nil { + if resp.Header != nil { result.MetaData = metadata.ParseFromHeaders(resp.Header) } } diff --git a/storage/2023-11-03/queue/messages/delete.go b/storage/2023-11-03/queue/messages/delete.go index cfec0a8..3db729e 100644 --- a/storage/2023-11-03/queue/messages/delete.go +++ b/storage/2023-11-03/queue/messages/delete.go @@ -57,7 +57,7 @@ func (c Client) Delete(ctx context.Context, queueName, messageID string, input D var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/queue/messages/get.go b/storage/2023-11-03/queue/messages/get.go index ae14dae..740af86 100644 --- a/storage/2023-11-03/queue/messages/get.go +++ b/storage/2023-11-03/queue/messages/get.go @@ -62,7 +62,7 @@ func (c Client) Get(ctx context.Context, queueName string, input GetInput) (resu var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response err = resp.Unmarshal(&result) diff --git a/storage/2023-11-03/queue/messages/peek.go b/storage/2023-11-03/queue/messages/peek.go index 1b8886c..dadc526 100644 --- a/storage/2023-11-03/queue/messages/peek.go +++ b/storage/2023-11-03/queue/messages/peek.go @@ -52,7 +52,7 @@ func (c Client) Peek(ctx context.Context, queueName string, input PeekInput) (re var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response err = resp.Unmarshal(&result) diff --git a/storage/2023-11-03/queue/messages/put.go b/storage/2023-11-03/queue/messages/put.go index d59f844..8cb247a 100644 --- a/storage/2023-11-03/queue/messages/put.go +++ b/storage/2023-11-03/queue/messages/put.go @@ -74,7 +74,7 @@ func (c Client) Put(ctx context.Context, queueName string, input PutInput) (resu var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response err = resp.Unmarshal(&result) diff --git a/storage/2023-11-03/queue/messages/update.go b/storage/2023-11-03/queue/messages/update.go index 15d266f..a92ac97 100644 --- a/storage/2023-11-03/queue/messages/update.go +++ b/storage/2023-11-03/queue/messages/update.go @@ -78,7 +78,7 @@ func (c Client) Update(ctx context.Context, queueName string, messageID string, var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/queue/queues/create.go b/storage/2023-11-03/queue/queues/create.go index f548088..8ced381 100644 --- a/storage/2023-11-03/queue/queues/create.go +++ b/storage/2023-11-03/queue/queues/create.go @@ -54,7 +54,7 @@ func (c Client) Create(ctx context.Context, queueName string, input CreateInput) var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/queue/queues/delete.go b/storage/2023-11-03/queue/queues/delete.go index e8d7bab..27ff802 100644 --- a/storage/2023-11-03/queue/queues/delete.go +++ b/storage/2023-11-03/queue/queues/delete.go @@ -42,7 +42,7 @@ func (c Client) Delete(ctx context.Context, queueName string) (result DeleteResp var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/queue/queues/metadata_get.go b/storage/2023-11-03/queue/queues/metadata_get.go index 9b98705..dc70d8e 100644 --- a/storage/2023-11-03/queue/queues/metadata_get.go +++ b/storage/2023-11-03/queue/queues/metadata_get.go @@ -46,10 +46,10 @@ func (c Client) GetMetaData(ctx context.Context, queueName string) (result GetMe var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response - if resp.Response != nil && resp.Header != nil { + if resp.Header != nil { result.MetaData = metadata.ParseFromHeaders(resp.Header) } } diff --git a/storage/2023-11-03/queue/queues/metadata_set.go b/storage/2023-11-03/queue/queues/metadata_set.go index 6ab770d..d01d013 100644 --- a/storage/2023-11-03/queue/queues/metadata_set.go +++ b/storage/2023-11-03/queue/queues/metadata_set.go @@ -54,7 +54,7 @@ func (c Client) SetMetaData(ctx context.Context, queueName string, input SetMeta var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/queue/queues/properties_get.go b/storage/2023-11-03/queue/queues/properties_get.go index 0647f26..ec250a5 100644 --- a/storage/2023-11-03/queue/queues/properties_get.go +++ b/storage/2023-11-03/queue/queues/properties_get.go @@ -35,7 +35,7 @@ func (c Client) GetServiceProperties(ctx context.Context) (result GetStorageServ var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response err = resp.Unmarshal(&result) diff --git a/storage/2023-11-03/queue/queues/properties_set.go b/storage/2023-11-03/queue/queues/properties_set.go index d80b672..c43d95e 100644 --- a/storage/2023-11-03/queue/queues/properties_set.go +++ b/storage/2023-11-03/queue/queues/properties_set.go @@ -51,7 +51,7 @@ func (c Client) SetServiceProperties(ctx context.Context, input SetStorageServic var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/table/entities/delete.go b/storage/2023-11-03/table/entities/delete.go index 61e7c71..fcef738 100644 --- a/storage/2023-11-03/table/entities/delete.go +++ b/storage/2023-11-03/table/entities/delete.go @@ -56,7 +56,7 @@ func (c Client) Delete(ctx context.Context, tableName string, input DeleteEntity var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/table/entities/get.go b/storage/2023-11-03/table/entities/get.go index daf428a..cb92d8b 100644 --- a/storage/2023-11-03/table/entities/get.go +++ b/storage/2023-11-03/table/entities/get.go @@ -56,7 +56,7 @@ func (c Client) Get(ctx context.Context, tableName string, input GetEntityInput) var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response err = resp.Unmarshal(&result.Entity) diff --git a/storage/2023-11-03/table/entities/insert.go b/storage/2023-11-03/table/entities/insert.go index 1996ba8..e0c06f6 100644 --- a/storage/2023-11-03/table/entities/insert.go +++ b/storage/2023-11-03/table/entities/insert.go @@ -73,7 +73,7 @@ func (c Client) Insert(ctx context.Context, tableName string, input InsertEntity var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/table/entities/insert_or_merge.go b/storage/2023-11-03/table/entities/insert_or_merge.go index 8ec8191..1b810fb 100644 --- a/storage/2023-11-03/table/entities/insert_or_merge.go +++ b/storage/2023-11-03/table/entities/insert_or_merge.go @@ -69,7 +69,7 @@ func (c Client) InsertOrMerge(ctx context.Context, tableName string, input Inser var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/table/entities/insert_or_replace.go b/storage/2023-11-03/table/entities/insert_or_replace.go index 269437c..ecabac7 100644 --- a/storage/2023-11-03/table/entities/insert_or_replace.go +++ b/storage/2023-11-03/table/entities/insert_or_replace.go @@ -69,7 +69,7 @@ func (c Client) InsertOrReplace(ctx context.Context, tableName string, input Ins var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/table/entities/query.go b/storage/2023-11-03/table/entities/query.go index 57b411a..3e3d75a 100644 --- a/storage/2023-11-03/table/entities/query.go +++ b/storage/2023-11-03/table/entities/query.go @@ -84,7 +84,7 @@ func (c Client) Query(ctx context.Context, tableName string, input QueryEntities var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response err = resp.Unmarshal(&result) diff --git a/storage/2023-11-03/table/tables/acl_get.go b/storage/2023-11-03/table/tables/acl_get.go index 3f2f2a1..dc34659 100644 --- a/storage/2023-11-03/table/tables/acl_get.go +++ b/storage/2023-11-03/table/tables/acl_get.go @@ -41,7 +41,7 @@ func (c Client) GetACL(ctx context.Context, tableName string) (result GetACLResp var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response err = resp.Unmarshal(&result) diff --git a/storage/2023-11-03/table/tables/acl_set.go b/storage/2023-11-03/table/tables/acl_set.go index 9749bd0..f1614bb 100644 --- a/storage/2023-11-03/table/tables/acl_set.go +++ b/storage/2023-11-03/table/tables/acl_set.go @@ -51,7 +51,7 @@ func (c Client) SetACL(ctx context.Context, tableName string, acls []SignedIdent var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/table/tables/create.go b/storage/2023-11-03/table/tables/create.go index 6adfd5a..682060c 100644 --- a/storage/2023-11-03/table/tables/create.go +++ b/storage/2023-11-03/table/tables/create.go @@ -47,7 +47,7 @@ func (c Client) Create(ctx context.Context, tableName string) (result CreateTabl var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/table/tables/delete.go b/storage/2023-11-03/table/tables/delete.go index b1fab65..1b4ec0d 100644 --- a/storage/2023-11-03/table/tables/delete.go +++ b/storage/2023-11-03/table/tables/delete.go @@ -38,7 +38,7 @@ func (c Client) Delete(ctx context.Context, tableName string) (result DeleteTabl var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/table/tables/exists.go b/storage/2023-11-03/table/tables/exists.go index dc8a43a..33f931b 100644 --- a/storage/2023-11-03/table/tables/exists.go +++ b/storage/2023-11-03/table/tables/exists.go @@ -38,7 +38,7 @@ func (c Client) Exists(ctx context.Context, tableName string) (result TableExist var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response } if err != nil { diff --git a/storage/2023-11-03/table/tables/query.go b/storage/2023-11-03/table/tables/query.go index 4cc07ea..92134e9 100644 --- a/storage/2023-11-03/table/tables/query.go +++ b/storage/2023-11-03/table/tables/query.go @@ -42,7 +42,7 @@ func (c Client) Query(ctx context.Context, input QueryInput) (result GetResponse var resp *client.Response resp, err = req.Execute(ctx) - if resp != nil { + if resp != nil && resp.Response != nil { result.HttpResponse = resp.Response err = resp.Unmarshal(&result) From 139b5e43d779b43bd8e0614719ebc179df20109b Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Fri, 5 Apr 2024 11:33:07 +0200 Subject: [PATCH 2/4] configuring the go version --- .go-version | 1 + 1 file changed, 1 insertion(+) create mode 100644 .go-version diff --git a/.go-version b/.go-version new file mode 100644 index 0000000..24b38a9 --- /dev/null +++ b/.go-version @@ -0,0 +1 @@ +1.22.1 \ No newline at end of file From 29e7fd4a95a647dadbb023337ec9d0e1d115e797 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Fri, 5 Apr 2024 11:45:38 +0200 Subject: [PATCH 3/4] going to 1.22.2 --- .go-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.go-version b/.go-version index 24b38a9..8864ad2 100644 --- a/.go-version +++ b/.go-version @@ -1 +1 @@ -1.22.1 \ No newline at end of file +1.22.2 \ No newline at end of file From bbf0f64b0cad3c33ac16e209830bb3d189d6fb2b Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Fri, 5 Apr 2024 12:45:04 +0200 Subject: [PATCH 4/4] `file/files`: fixing a bug in Get File where we'd try and unmarshal the file --- storage/2023-11-03/file/files/range_get.go | 18 +++++++++++++----- .../2023-11-03/file/files/range_get_file.go | 3 +++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/storage/2023-11-03/file/files/range_get.go b/storage/2023-11-03/file/files/range_get.go index 9b2dec4..7d2d4c5 100644 --- a/storage/2023-11-03/file/files/range_get.go +++ b/storage/2023-11-03/file/files/range_get.go @@ -3,6 +3,8 @@ package files import ( "context" "fmt" + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "io" "net/http" "strings" @@ -83,13 +85,19 @@ func (c Client) GetByteRange(ctx context.Context, shareName, path, fileName stri var resp *client.Response resp, err = req.Execute(ctx) if resp != nil && resp.Response != nil { - result.Contents = &[]byte{} result.HttpResponse = resp.Response - err = resp.Unmarshal(result.Contents) - if err != nil { - err = fmt.Errorf("unmarshalling response: %+v", err) - return + result.Contents = &[]byte{} + if resp.Body != nil { + respBody, err := io.ReadAll(resp.Body) + defer resp.Body.Close() + if err != nil { + return result, fmt.Errorf("could not parse response body") + } + + if respBody != nil { + result.Contents = pointer.To(respBody) + } } } if err != nil { diff --git a/storage/2023-11-03/file/files/range_get_file.go b/storage/2023-11-03/file/files/range_get_file.go index e923eb3..2551c1e 100644 --- a/storage/2023-11-03/file/files/range_get_file.go +++ b/storage/2023-11-03/file/files/range_get_file.go @@ -93,6 +93,9 @@ func (c Client) GetFile(ctx context.Context, shareName, path, fileName string, i copy(output[v.startBytes:v.endBytes], *v.bytes) } + if result.OutputBytes == nil { + result.OutputBytes = &[]byte{} + } *result.OutputBytes = output return }