From 50992c4c5cd229891daf0cc2cf66af2b80f99677 Mon Sep 17 00:00:00 2001 From: Tom Bamford Date: Thu, 8 Feb 2024 14:07:53 +0000 Subject: [PATCH 1/3] dependencies: updating to v0.20240223.1153421 of `github.com/hashicorp/go-azure-sdk/sdk` and v0.66.2 of `github.com/hashicorp/go-azure-helpers` --- go.mod | 6 +++--- go.sum | 14 ++++++++++---- storage/2020-08-04/blob/blobs/README.md | 2 +- storage/2020-08-04/blob/containers/README.md | 2 +- .../2020-08-04/datalakestore/filesystems/README.md | 2 +- storage/2020-08-04/file/directories/README.md | 2 +- storage/2020-08-04/file/files/README.md | 2 +- storage/2020-08-04/file/shares/README.md | 2 +- storage/2020-08-04/queue/messages/README.md | 2 +- storage/2020-08-04/queue/queues/README.md | 2 +- storage/2020-08-04/table/entities/README.md | 2 +- storage/2020-08-04/table/tables/README.md | 2 +- storage/2023-11-03/blob/blobs/README.md | 2 +- storage/2023-11-03/blob/containers/README.md | 2 +- .../2023-11-03/datalakestore/filesystems/README.md | 2 +- storage/2023-11-03/file/directories/README.md | 2 +- storage/2023-11-03/file/files/README.md | 2 +- storage/2023-11-03/file/shares/README.md | 2 +- storage/2023-11-03/queue/messages/README.md | 2 +- storage/2023-11-03/queue/queues/README.md | 2 +- storage/2023-11-03/table/entities/README.md | 2 +- storage/2023-11-03/table/tables/README.md | 2 +- storage/internal/testhelpers/client.go | 4 ++-- 23 files changed, 35 insertions(+), 29 deletions(-) diff --git a/go.mod b/go.mod index d99edcf..d3e966f 100644 --- a/go.mod +++ b/go.mod @@ -6,9 +6,9 @@ toolchain go1.21.3 require ( github.com/google/uuid v1.4.0 - github.com/hashicorp/go-azure-helpers v0.66.1 - github.com/hashicorp/go-azure-sdk/resource-manager v0.20240125.1111756 - github.com/hashicorp/go-azure-sdk/sdk v0.20240125.1115017 + github.com/hashicorp/go-azure-helpers v0.66.2 + github.com/hashicorp/go-azure-sdk/resource-manager v0.20240223.1153421 + github.com/hashicorp/go-azure-sdk/sdk v0.20240223.1153421 github.com/stretchr/testify v1.8.4 ) diff --git a/go.sum b/go.sum index 09f50a6..b7e3d32 100644 --- a/go.sum +++ b/go.sum @@ -27,12 +27,18 @@ github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/go-azure-helpers v0.66.1 h1:SokAckK9hvQ9PZO2TmZY/CGru8KWJ4A7hcRUggHMEus= -github.com/hashicorp/go-azure-helpers v0.66.1/go.mod h1:kJxXrFtJKJdOEqvad8pllAe7dhP4DbN8J6sqFZe47+4= +github.com/hashicorp/go-azure-helpers v0.66.2 h1:+Pzuo7pdKl0hBXXr5ymmhs4Q40tHAo2nAvHq4WgSjx8= +github.com/hashicorp/go-azure-helpers v0.66.2/go.mod h1:kJxXrFtJKJdOEqvad8pllAe7dhP4DbN8J6sqFZe47+4= +github.com/hashicorp/go-azure-sdk v0.20240125.1100331 h1:mMgROkPDJnzyDyGwogjhjbD62pVowy3eNk1k6ozwcZA= +github.com/hashicorp/go-azure-sdk v0.20240125.1100331/go.mod h1:3KI/ojBQAAMjtXPxCP9A5EyNMWlDQarITxGLmGj9tGI= github.com/hashicorp/go-azure-sdk/resource-manager v0.20240125.1111756 h1:foZtDGwC7q/QKer3B9Df+FwkAJn1auc/8LMqR8QWk64= github.com/hashicorp/go-azure-sdk/resource-manager v0.20240125.1111756/go.mod h1:yWRLLjG7PVThIY1NLeLNhp0VtTewOCFrIVIZl/LgPBc= -github.com/hashicorp/go-azure-sdk/sdk v0.20240125.1115017 h1:9to4aRjOrmfm0XVBp5IqNFnjtpChVKSdskNa88qfZzc= -github.com/hashicorp/go-azure-sdk/sdk v0.20240125.1115017/go.mod h1:6jgkzx26qtPndLSW5u7pKIw4m3iiFiLnHlp7yDQ2Crc= +github.com/hashicorp/go-azure-sdk/resource-manager v0.20240223.1153421 h1:RrPR6RGkkvfWoP+UkmzWNQwoIVsFO/Oj+8lQqQw3880= +github.com/hashicorp/go-azure-sdk/resource-manager v0.20240223.1153421/go.mod h1:gm/5ZkCKtVTV1sSHyMql5a8tB0Z5NBXjF0MGB7Q8chg= +github.com/hashicorp/go-azure-sdk/sdk v0.20240219.1162257-0.20240220115734-eeb1a5d96f9a h1:9Qg8M1Yp3WGmJw0FyAeg/4VXmp0m+6kfSJ//etdAfLk= +github.com/hashicorp/go-azure-sdk/sdk v0.20240219.1162257-0.20240220115734-eeb1a5d96f9a/go.mod h1:IKIPyL+hfFWBHABKT0NOWlIEzlusiUBG0SxIfaiv278= +github.com/hashicorp/go-azure-sdk/sdk v0.20240223.1153421 h1:unXuyut6yDlY9kaoworHj2f1gd/c+mSf8qh3WkMyB1Q= +github.com/hashicorp/go-azure-sdk/sdk v0.20240223.1153421/go.mod h1:IKIPyL+hfFWBHABKT0NOWlIEzlusiUBG0SxIfaiv278= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 h1:1/D3zfFHttUKaCaGKZ/dR2roBXv0vKbSCnssIldfQdI= diff --git a/storage/2020-08-04/blob/blobs/README.md b/storage/2020-08-04/blob/blobs/README.md index 4afa786..aa5ebd1 100644 --- a/storage/2020-08-04/blob/blobs/README.md +++ b/storage/2020-08-04/blob/blobs/README.md @@ -37,7 +37,7 @@ func Example() error { if err != nil { return fmt.Errorf("building SharedKey authorizer: %+v", err) } - blobClient.Client.WithAuthorizer(auth) + blobClient.Client.SetAuthorizer(auth) ctx := context.TODO() copyInput := blobs.CopyInput{ diff --git a/storage/2020-08-04/blob/containers/README.md b/storage/2020-08-04/blob/containers/README.md index fcebd03..c935287 100644 --- a/storage/2020-08-04/blob/containers/README.md +++ b/storage/2020-08-04/blob/containers/README.md @@ -37,7 +37,7 @@ func Example() error { if err != nil { return fmt.Errorf("building SharedKey authorizer: %+v", err) } - containersClient.Client.WithAuthorizer(auth) + containersClient.Client.SetAuthorizer(auth) ctx := context.TODO() createInput := containers.CreateInput{ diff --git a/storage/2020-08-04/datalakestore/filesystems/README.md b/storage/2020-08-04/datalakestore/filesystems/README.md index 2ba3786..df369cc 100644 --- a/storage/2020-08-04/datalakestore/filesystems/README.md +++ b/storage/2020-08-04/datalakestore/filesystems/README.md @@ -38,7 +38,7 @@ func Example() error { if err != nil { return fmt.Errorf("building client for environment: %+v", err) } - fileSystemsClient.Client.WithAuthorizer(auth) + fileSystemsClient.Client.SetAuthorizer(auth) input := filesystems.CreateInput{ Properties: map[string]string{}, diff --git a/storage/2020-08-04/file/directories/README.md b/storage/2020-08-04/file/directories/README.md index 0ec880f..602f0a6 100644 --- a/storage/2020-08-04/file/directories/README.md +++ b/storage/2020-08-04/file/directories/README.md @@ -40,7 +40,7 @@ func Example() error { if err != nil { return fmt.Errorf("building client for environment: %+v", err) } - directoriesClient.Client.WithAuthorizer(auth) + directoriesClient.Client.SetAuthorizer(auth) ctx := context.TODO() metadata := map[string]string{ diff --git a/storage/2020-08-04/file/files/README.md b/storage/2020-08-04/file/files/README.md index 9070e23..dc8df5f 100644 --- a/storage/2020-08-04/file/files/README.md +++ b/storage/2020-08-04/file/files/README.md @@ -41,7 +41,7 @@ func Example() error { if err != nil { return fmt.Errorf("building client for environment: %+v", err) } - filesClient.Client.WithAuthorizer(auth) + filesClient.Client.SetAuthorizer(auth) ctx := context.TODO() input := files.CreateInput{} diff --git a/storage/2020-08-04/file/shares/README.md b/storage/2020-08-04/file/shares/README.md index 314895f..68b41e2 100644 --- a/storage/2020-08-04/file/shares/README.md +++ b/storage/2020-08-04/file/shares/README.md @@ -35,7 +35,7 @@ func Example() error { if err != nil { return fmt.Errorf("building SharedKey authorizer: %+v", err) } - sharesClient.Client.WithAuthorizer(auth) + sharesClient.Client.SetAuthorizer(auth) ctx := context.TODO() input := shares.CreateInput{ diff --git a/storage/2020-08-04/queue/messages/README.md b/storage/2020-08-04/queue/messages/README.md index 18674d0..35b9336 100644 --- a/storage/2020-08-04/queue/messages/README.md +++ b/storage/2020-08-04/queue/messages/README.md @@ -35,7 +35,7 @@ func Example() error { if err != nil { return fmt.Errorf("building client for environment: %+v", err) } - messagesClient.Client.WithAuthorizer(auth) + messagesClient.Client.SetAuthorizer(auth) ctx := context.TODO() input := messages.PutInput{ diff --git a/storage/2020-08-04/queue/queues/README.md b/storage/2020-08-04/queue/queues/README.md index c423c71..7c9fd1a 100644 --- a/storage/2020-08-04/queue/queues/README.md +++ b/storage/2020-08-04/queue/queues/README.md @@ -35,7 +35,7 @@ func Example() error { if err != nil { return fmt.Errorf("building client for environment: %+v", err) } - queuesClient.Client.WithAuthorizer(auth) + queuesClient.Client.SetAuthorizer(auth) ctx := context.TODO() metadata := map[string]string{ diff --git a/storage/2020-08-04/table/entities/README.md b/storage/2020-08-04/table/entities/README.md index 91c2096..e98e21e 100644 --- a/storage/2020-08-04/table/entities/README.md +++ b/storage/2020-08-04/table/entities/README.md @@ -34,7 +34,7 @@ func Example() error { if err != nil { return fmt.Errorf("building client for environment: %+v", err) } - entitiesClient.Client.WithAuthorizer(auth) + entitiesClient.Client.SetAuthorizer(auth) ctx := context.TODO() input := entities.InsertEntityInput{ diff --git a/storage/2020-08-04/table/tables/README.md b/storage/2020-08-04/table/tables/README.md index 2ef6621..a6b5ee2 100644 --- a/storage/2020-08-04/table/tables/README.md +++ b/storage/2020-08-04/table/tables/README.md @@ -33,7 +33,7 @@ func Example() error { if err != nil { return fmt.Errorf("building client for environment: %+v", err) } - tablesClient.Client.WithAuthorizer(auth) + tablesClient.Client.SetAuthorizer(auth) ctx := context.TODO() if _, err := tablesClient.Create(ctx, tableName); err != nil { diff --git a/storage/2023-11-03/blob/blobs/README.md b/storage/2023-11-03/blob/blobs/README.md index 276ddc3..0b26e1c 100644 --- a/storage/2023-11-03/blob/blobs/README.md +++ b/storage/2023-11-03/blob/blobs/README.md @@ -37,7 +37,7 @@ func Example() error { if err != nil { return fmt.Errorf("building SharedKey authorizer: %+v", err) } - blobClient.Client.WithAuthorizer(auth) + blobClient.Client.SetAuthorizer(auth) ctx := context.TODO() copyInput := blobs.CopyInput{ diff --git a/storage/2023-11-03/blob/containers/README.md b/storage/2023-11-03/blob/containers/README.md index 24b243e..6283cd7 100644 --- a/storage/2023-11-03/blob/containers/README.md +++ b/storage/2023-11-03/blob/containers/README.md @@ -37,7 +37,7 @@ func Example() error { if err != nil { return fmt.Errorf("building SharedKey authorizer: %+v", err) } - containersClient.Client.WithAuthorizer(auth) + containersClient.Client.SetAuthorizer(auth) ctx := context.TODO() createInput := containers.CreateInput{ diff --git a/storage/2023-11-03/datalakestore/filesystems/README.md b/storage/2023-11-03/datalakestore/filesystems/README.md index cfbc2b6..ac35149 100644 --- a/storage/2023-11-03/datalakestore/filesystems/README.md +++ b/storage/2023-11-03/datalakestore/filesystems/README.md @@ -37,7 +37,7 @@ func Example() error { if err != nil { return fmt.Errorf("building client for environment: %+v", err) } - fileSystemsClient.Client.WithAuthorizer(auth) + fileSystemsClient.Client.SetAuthorizer(auth) input := filesystems.CreateInput{ Properties: map[string]string{}, diff --git a/storage/2023-11-03/file/directories/README.md b/storage/2023-11-03/file/directories/README.md index 4dd905c..d81f7b0 100644 --- a/storage/2023-11-03/file/directories/README.md +++ b/storage/2023-11-03/file/directories/README.md @@ -40,7 +40,7 @@ func Example() error { if err != nil { return fmt.Errorf("building client for environment: %+v", err) } - directoriesClient.Client.WithAuthorizer(auth) + directoriesClient.Client.SetAuthorizer(auth) ctx := context.TODO() metadata := map[string]string{ diff --git a/storage/2023-11-03/file/files/README.md b/storage/2023-11-03/file/files/README.md index a8126e6..0ac6146 100644 --- a/storage/2023-11-03/file/files/README.md +++ b/storage/2023-11-03/file/files/README.md @@ -41,7 +41,7 @@ func Example() error { if err != nil { return fmt.Errorf("building client for environment: %+v", err) } - filesClient.Client.WithAuthorizer(auth) + filesClient.Client.SetAuthorizer(auth) ctx := context.TODO() input := files.CreateInput{} diff --git a/storage/2023-11-03/file/shares/README.md b/storage/2023-11-03/file/shares/README.md index 0a7067d..5ec0fb4 100644 --- a/storage/2023-11-03/file/shares/README.md +++ b/storage/2023-11-03/file/shares/README.md @@ -35,7 +35,7 @@ func Example() error { if err != nil { return fmt.Errorf("building SharedKey authorizer: %+v", err) } - sharesClient.Client.WithAuthorizer(auth) + sharesClient.Client.SetAuthorizer(auth) ctx := context.TODO() input := shares.CreateInput{ diff --git a/storage/2023-11-03/queue/messages/README.md b/storage/2023-11-03/queue/messages/README.md index f2c1ba2..5373017 100644 --- a/storage/2023-11-03/queue/messages/README.md +++ b/storage/2023-11-03/queue/messages/README.md @@ -35,7 +35,7 @@ func Example() error { if err != nil { return fmt.Errorf("building client for environment: %+v", err) } - messagesClient.Client.WithAuthorizer(auth) + messagesClient.Client.SetAuthorizer(auth) ctx := context.TODO() input := messages.PutInput{ diff --git a/storage/2023-11-03/queue/queues/README.md b/storage/2023-11-03/queue/queues/README.md index d18203f..745cc6d 100644 --- a/storage/2023-11-03/queue/queues/README.md +++ b/storage/2023-11-03/queue/queues/README.md @@ -35,7 +35,7 @@ func Example() error { if err != nil { return fmt.Errorf("building client for environment: %+v", err) } - queuesClient.Client.WithAuthorizer(auth) + queuesClient.Client.SetAuthorizer(auth) ctx := context.TODO() metadata := map[string]string{ diff --git a/storage/2023-11-03/table/entities/README.md b/storage/2023-11-03/table/entities/README.md index edaeb89..06b519b 100644 --- a/storage/2023-11-03/table/entities/README.md +++ b/storage/2023-11-03/table/entities/README.md @@ -34,7 +34,7 @@ func Example() error { if err != nil { return fmt.Errorf("building client for environment: %+v", err) } - entitiesClient.Client.WithAuthorizer(auth) + entitiesClient.Client.SetAuthorizer(auth) ctx := context.TODO() input := entities.InsertEntityInput{ diff --git a/storage/2023-11-03/table/tables/README.md b/storage/2023-11-03/table/tables/README.md index 1f99d18..65a459f 100644 --- a/storage/2023-11-03/table/tables/README.md +++ b/storage/2023-11-03/table/tables/README.md @@ -33,7 +33,7 @@ func Example() error { if err != nil { return fmt.Errorf("building client for environment: %+v", err) } - tablesClient.Client.WithAuthorizer(auth) + tablesClient.Client.SetAuthorizer(auth) ctx := context.TODO() if _, err := tablesClient.Create(ctx, tableName); err != nil { diff --git a/storage/internal/testhelpers/client.go b/storage/internal/testhelpers/client.go index b611892..7116a9b 100644 --- a/storage/internal/testhelpers/client.go +++ b/storage/internal/testhelpers/client.go @@ -180,7 +180,7 @@ func (c Client) Configure(client *client.Client, authorizer auth.Authorizer) { } func (c Client) PrepareWithResourceManagerAuth(input *storage.BaseClient) { - input.WithAuthorizer(c.storageAuth) + input.SetAuthorizer(c.storageAuth) } func (c Client) PrepareWithSharedKeyAuth(input *storage.BaseClient, data *TestResources, keyType auth.SharedKeyType) error { @@ -188,6 +188,6 @@ func (c Client) PrepareWithSharedKeyAuth(input *storage.BaseClient, data *TestRe if err != nil { return fmt.Errorf("building SharedKey authorizer: %+v", err) } - input.WithAuthorizer(auth) + input.SetAuthorizer(auth) return nil } From b48d859a0c8b815965e272f76e2cabd0787c6e59 Mon Sep 17 00:00:00 2001 From: Tom Bamford Date: Tue, 20 Feb 2024 12:17:29 +0000 Subject: [PATCH 2/3] Improve unmarshaling for binary payloads, implement retries when creating file shares --- storage/2020-08-04/blob/accounts/client.go | 4 +-- storage/2020-08-04/blob/blobs/client.go | 4 +-- storage/2020-08-04/blob/containers/client.go | 4 +-- .../datalakestore/filesystems/client.go | 4 +-- .../2020-08-04/datalakestore/paths/client.go | 4 +-- storage/2020-08-04/file/directories/client.go | 4 +-- storage/2020-08-04/file/files/client.go | 4 +-- storage/2020-08-04/file/shares/client.go | 4 +-- storage/2020-08-04/queue/messages/client.go | 4 +-- storage/2020-08-04/queue/queues/client.go | 4 +-- storage/2020-08-04/table/entities/client.go | 4 +-- storage/2020-08-04/table/tables/client.go | 4 +-- storage/2023-11-03/blob/accounts/client.go | 4 +-- storage/2023-11-03/blob/blobs/append_block.go | 10 +++--- storage/2023-11-03/blob/blobs/client.go | 4 +-- storage/2023-11-03/blob/blobs/get.go | 5 +-- storage/2023-11-03/blob/blobs/put_block.go | 12 +++---- .../2023-11-03/blob/blobs/put_block_blob.go | 6 +++- storage/2023-11-03/blob/containers/client.go | 4 +-- storage/2023-11-03/blob/containers/create.go | 32 +++++++++++++++++-- storage/2023-11-03/blob/containers/models.go | 7 ++-- .../datalakestore/filesystems/client.go | 4 +-- .../2023-11-03/datalakestore/paths/client.go | 4 +-- storage/2023-11-03/file/directories/client.go | 4 +-- storage/2023-11-03/file/files/client.go | 4 +-- storage/2023-11-03/file/files/range_get.go | 10 +++--- .../2023-11-03/file/files/range_get_file.go | 9 +++--- .../file/files/range_get_file_test.go | 9 +++--- storage/2023-11-03/file/shares/acl_set.go | 3 +- storage/2023-11-03/file/shares/client.go | 4 +-- storage/2023-11-03/file/shares/create.go | 30 ++++++++++++++++- storage/2023-11-03/file/shares/models.go | 8 +++++ storage/2023-11-03/queue/messages/client.go | 4 +-- storage/2023-11-03/queue/queues/client.go | 4 +-- storage/2023-11-03/table/entities/client.go | 4 +-- storage/2023-11-03/table/tables/client.go | 4 +-- storage/internal/testhelpers/client.go | 4 +-- 37 files changed, 154 insertions(+), 87 deletions(-) diff --git a/storage/2020-08-04/blob/accounts/client.go b/storage/2020-08-04/blob/accounts/client.go index 1a3c314..df5fa1d 100644 --- a/storage/2020-08-04/blob/accounts/client.go +++ b/storage/2020-08-04/blob/accounts/client.go @@ -8,11 +8,11 @@ import ( // Client is the base client for Blob Storage Blobs. type Client struct { - Client *storage.BaseClient + Client *storage.Client } func NewWithBaseUri(baseUri string) (*Client, error) { - baseClient, err := storage.NewBaseClient(baseUri, componentName, apiVersion) + baseClient, err := storage.NewStorageClient(baseUri, componentName, apiVersion) if err != nil { return nil, fmt.Errorf("building base client: %+v", err) } diff --git a/storage/2020-08-04/blob/blobs/client.go b/storage/2020-08-04/blob/blobs/client.go index 8cb42d8..4bb762b 100644 --- a/storage/2020-08-04/blob/blobs/client.go +++ b/storage/2020-08-04/blob/blobs/client.go @@ -8,11 +8,11 @@ import ( // Client is the base client for Blob Storage Blobs. type Client struct { - Client *storage.BaseClient + Client *storage.Client } func NewWithBaseUri(baseUri string) (*Client, error) { - baseClient, err := storage.NewBaseClient(baseUri, componentName, apiVersion) + baseClient, err := storage.NewStorageClient(baseUri, componentName, apiVersion) if err != nil { return nil, fmt.Errorf("building base client: %+v", err) } diff --git a/storage/2020-08-04/blob/containers/client.go b/storage/2020-08-04/blob/containers/client.go index 72174cb..ae8c43a 100644 --- a/storage/2020-08-04/blob/containers/client.go +++ b/storage/2020-08-04/blob/containers/client.go @@ -8,11 +8,11 @@ import ( // Client is the base client for Blob Storage Containers. type Client struct { - Client *storage.BaseClient + Client *storage.Client } func NewWithBaseUri(baseUri string) (*Client, error) { - baseClient, err := storage.NewBaseClient(baseUri, componentName, apiVersion) + baseClient, err := storage.NewStorageClient(baseUri, componentName, apiVersion) if err != nil { return nil, fmt.Errorf("building base client: %+v", err) } diff --git a/storage/2020-08-04/datalakestore/filesystems/client.go b/storage/2020-08-04/datalakestore/filesystems/client.go index 27e96d1..a121733 100644 --- a/storage/2020-08-04/datalakestore/filesystems/client.go +++ b/storage/2020-08-04/datalakestore/filesystems/client.go @@ -8,11 +8,11 @@ import ( // Client is the base client for Data Lake Store Filesystems. type Client struct { - Client *storage.BaseClient + Client *storage.Client } func NewWithBaseUri(baseUri string) (*Client, error) { - baseClient, err := storage.NewBaseClient(baseUri, componentName, apiVersion) + baseClient, err := storage.NewStorageClient(baseUri, componentName, apiVersion) if err != nil { return nil, fmt.Errorf("building base client: %+v", err) } diff --git a/storage/2020-08-04/datalakestore/paths/client.go b/storage/2020-08-04/datalakestore/paths/client.go index 27e70be..e0cb427 100644 --- a/storage/2020-08-04/datalakestore/paths/client.go +++ b/storage/2020-08-04/datalakestore/paths/client.go @@ -7,11 +7,11 @@ import ( // Client is the base client for Data Lake Storage Path type Client struct { - Client *storage.BaseClient + Client *storage.Client } func NewWithBaseUri(baseUri string) (*Client, error) { - baseClient, err := storage.NewBaseClient(baseUri, componentName, apiVersion) + baseClient, err := storage.NewStorageClient(baseUri, componentName, apiVersion) if err != nil { return nil, fmt.Errorf("building base client: %+v", err) } diff --git a/storage/2020-08-04/file/directories/client.go b/storage/2020-08-04/file/directories/client.go index 86f9fd1..7b327f0 100644 --- a/storage/2020-08-04/file/directories/client.go +++ b/storage/2020-08-04/file/directories/client.go @@ -8,11 +8,11 @@ import ( // Client is the base client for File Storage Shares. type Client struct { - Client *storage.BaseClient + Client *storage.Client } func NewWithBaseUri(baseUri string) (*Client, error) { - baseClient, err := storage.NewBaseClient(baseUri, componentName, apiVersion) + baseClient, err := storage.NewStorageClient(baseUri, componentName, apiVersion) if err != nil { return nil, fmt.Errorf("building base client: %+v", err) } diff --git a/storage/2020-08-04/file/files/client.go b/storage/2020-08-04/file/files/client.go index a875c77..cee19a3 100644 --- a/storage/2020-08-04/file/files/client.go +++ b/storage/2020-08-04/file/files/client.go @@ -8,11 +8,11 @@ import ( // Client is the base client for File Storage Shares. type Client struct { - Client *storage.BaseClient + Client *storage.Client } func NewWithBaseUri(baseUri string) (*Client, error) { - baseClient, err := storage.NewBaseClient(baseUri, componentName, apiVersion) + baseClient, err := storage.NewStorageClient(baseUri, componentName, apiVersion) if err != nil { return nil, fmt.Errorf("building base client: %+v", err) } diff --git a/storage/2020-08-04/file/shares/client.go b/storage/2020-08-04/file/shares/client.go index 6e5fd15..7d6516f 100644 --- a/storage/2020-08-04/file/shares/client.go +++ b/storage/2020-08-04/file/shares/client.go @@ -8,11 +8,11 @@ import ( // Client is the base client for File Storage Shares. type Client struct { - Client *storage.BaseClient + Client *storage.Client } func NewWithBaseUri(baseUri string) (*Client, error) { - baseClient, err := storage.NewBaseClient(baseUri, componentName, apiVersion) + baseClient, err := storage.NewStorageClient(baseUri, componentName, apiVersion) if err != nil { return nil, fmt.Errorf("building base client: %+v", err) } diff --git a/storage/2020-08-04/queue/messages/client.go b/storage/2020-08-04/queue/messages/client.go index ec5d64c..a3312a2 100644 --- a/storage/2020-08-04/queue/messages/client.go +++ b/storage/2020-08-04/queue/messages/client.go @@ -8,11 +8,11 @@ import ( // Client is the base client for Messages. type Client struct { - Client *storage.BaseClient + Client *storage.Client } func NewWithBaseUri(baseUri string) (*Client, error) { - baseClient, err := storage.NewBaseClient(baseUri, componentName, apiVersion) + baseClient, err := storage.NewStorageClient(baseUri, componentName, apiVersion) if err != nil { return nil, fmt.Errorf("building base client: %+v", err) } diff --git a/storage/2020-08-04/queue/queues/client.go b/storage/2020-08-04/queue/queues/client.go index 40aa674..4497f0e 100644 --- a/storage/2020-08-04/queue/queues/client.go +++ b/storage/2020-08-04/queue/queues/client.go @@ -10,11 +10,11 @@ import ( // Client is the base client for Messages. type Client struct { - Client *storage.BaseClient + Client *storage.Client } func NewWithBaseUri(baseUri string) (*Client, error) { - baseClient, err := storage.NewBaseClient(baseUri, componentName, apiVersion) + baseClient, err := storage.NewStorageClient(baseUri, componentName, apiVersion) if err != nil { return nil, fmt.Errorf("building base client: %+v", err) } diff --git a/storage/2020-08-04/table/entities/client.go b/storage/2020-08-04/table/entities/client.go index d1182ea..e190af6 100644 --- a/storage/2020-08-04/table/entities/client.go +++ b/storage/2020-08-04/table/entities/client.go @@ -8,11 +8,11 @@ import ( // Client is the base client for Table Storage Shares. type Client struct { - Client *storage.BaseClient + Client *storage.Client } func NewWithBaseUri(baseUri string) (*Client, error) { - baseClient, err := storage.NewBaseClient(baseUri, componentName, apiVersion) + baseClient, err := storage.NewStorageClient(baseUri, componentName, apiVersion) if err != nil { return nil, fmt.Errorf("building base client: %+v", err) } diff --git a/storage/2020-08-04/table/tables/client.go b/storage/2020-08-04/table/tables/client.go index 31e53c5..49c714d 100644 --- a/storage/2020-08-04/table/tables/client.go +++ b/storage/2020-08-04/table/tables/client.go @@ -8,11 +8,11 @@ import ( // Client is the base client for Table Storage Shares. type Client struct { - Client *storage.BaseClient + Client *storage.Client } func NewWithBaseUri(baseUri string) (*Client, error) { - baseClient, err := storage.NewBaseClient(baseUri, componentName, apiVersion) + baseClient, err := storage.NewStorageClient(baseUri, componentName, apiVersion) if err != nil { return nil, fmt.Errorf("building base client: %+v", err) } diff --git a/storage/2023-11-03/blob/accounts/client.go b/storage/2023-11-03/blob/accounts/client.go index 1a3c314..df5fa1d 100644 --- a/storage/2023-11-03/blob/accounts/client.go +++ b/storage/2023-11-03/blob/accounts/client.go @@ -8,11 +8,11 @@ import ( // Client is the base client for Blob Storage Blobs. type Client struct { - Client *storage.BaseClient + Client *storage.Client } func NewWithBaseUri(baseUri string) (*Client, error) { - baseClient, err := storage.NewBaseClient(baseUri, componentName, apiVersion) + baseClient, err := storage.NewStorageClient(baseUri, componentName, apiVersion) if err != nil { return nil, fmt.Errorf("building base client: %+v", err) } diff --git a/storage/2023-11-03/blob/blobs/append_block.go b/storage/2023-11-03/blob/blobs/append_block.go index 7a1779e..b82558f 100644 --- a/storage/2023-11-03/blob/blobs/append_block.go +++ b/storage/2023-11-03/blob/blobs/append_block.go @@ -1,10 +1,8 @@ package blobs import ( - "bytes" "context" "fmt" - "io" "net/http" "strconv" "strings" @@ -96,12 +94,12 @@ func (c Client) AppendBlock(ctx context.Context, containerName, blobName string, return } - if input.Content != nil { - req.Body = io.NopCloser(bytes.NewReader(*input.Content)) + err = req.Marshal(input.Content) + if err != nil { + err = fmt.Errorf("marshalling request: %+v", err) + return } - req.ContentLength = int64(len(*input.Content)) - var resp *client.Response resp, err = req.Execute(ctx) if resp != nil { diff --git a/storage/2023-11-03/blob/blobs/client.go b/storage/2023-11-03/blob/blobs/client.go index 8cb42d8..4bb762b 100644 --- a/storage/2023-11-03/blob/blobs/client.go +++ b/storage/2023-11-03/blob/blobs/client.go @@ -8,11 +8,11 @@ import ( // Client is the base client for Blob Storage Blobs. type Client struct { - Client *storage.BaseClient + Client *storage.Client } func NewWithBaseUri(baseUri string) (*Client, error) { - baseClient, err := storage.NewBaseClient(baseUri, componentName, apiVersion) + baseClient, err := storage.NewStorageClient(baseUri, componentName, apiVersion) if err != nil { return nil, fmt.Errorf("building base client: %+v", err) } diff --git a/storage/2023-11-03/blob/blobs/get.go b/storage/2023-11-03/blob/blobs/get.go index c108a32..5829324 100644 --- a/storage/2023-11-03/blob/blobs/get.go +++ b/storage/2023-11-03/blob/blobs/get.go @@ -19,7 +19,7 @@ type GetInput struct { type GetResponse struct { HttpResponse *http.Response - Contents []byte + Contents *[]byte } // Get reads or downloads a blob from the system, including its metadata and properties. @@ -65,9 +65,10 @@ func (c Client) Get(ctx context.Context, containerName, blobName string, input G var resp *client.Response resp, err = req.Execute(ctx) if resp != nil { + result.Contents = &[]byte{} result.HttpResponse = resp.Response - err = resp.Unmarshal(&result.Contents) + err = resp.Unmarshal(result.Contents) if err != nil { err = fmt.Errorf("unmarshalling response: %+v", err) return diff --git a/storage/2023-11-03/blob/blobs/put_block.go b/storage/2023-11-03/blob/blobs/put_block.go index 1dfb423..f261dde 100644 --- a/storage/2023-11-03/blob/blobs/put_block.go +++ b/storage/2023-11-03/blob/blobs/put_block.go @@ -1,8 +1,10 @@ package blobs import ( + "bytes" "context" "fmt" + "io" "net/http" "strconv" "strings" @@ -21,8 +23,7 @@ type PutBlockInput struct { type PutBlockResponse struct { HttpResponse *http.Response - - ContentMD5 string + ContentMD5 string } // PutBlock creates a new block to be committed as part of a blob. @@ -69,11 +70,8 @@ func (c Client) PutBlock(ctx context.Context, containerName, blobName string, in return } - err = req.Marshal(&input.Content) - if err != nil { - err = fmt.Errorf("marshalling request: %+v", err) - return - } + req.ContentLength = int64(len(input.Content)) + req.Body = io.NopCloser(bytes.NewReader(input.Content)) var resp *client.Response resp, err = req.Execute(ctx) 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 d643d13..d5d6773 100644 --- a/storage/2023-11-03/blob/blobs/put_block_blob.go +++ b/storage/2023-11-03/blob/blobs/put_block_blob.go @@ -68,13 +68,17 @@ func (c Client) PutBlockBlob(ctx context.Context, containerName, blobName string Path: fmt.Sprintf("/%s/%s", containerName, blobName), } + if input.ContentType != nil { + opts.ContentType = *input.ContentType + } + req, err := c.Client.NewRequest(ctx, opts) if err != nil { err = fmt.Errorf("building request: %+v", err) return } - err = req.Marshal(&input.Content) + err = req.Marshal(input.Content) if err != nil { err = fmt.Errorf("marshalling request: %+v", err) return diff --git a/storage/2023-11-03/blob/containers/client.go b/storage/2023-11-03/blob/containers/client.go index 72174cb..ae8c43a 100644 --- a/storage/2023-11-03/blob/containers/client.go +++ b/storage/2023-11-03/blob/containers/client.go @@ -8,11 +8,11 @@ import ( // Client is the base client for Blob Storage Containers. type Client struct { - Client *storage.BaseClient + Client *storage.Client } func NewWithBaseUri(baseUri string) (*Client, error) { - baseClient, err := storage.NewBaseClient(baseUri, componentName, apiVersion) + baseClient, err := storage.NewStorageClient(baseUri, componentName, apiVersion) if err != nil { return nil, fmt.Errorf("building base client: %+v", err) } diff --git a/storage/2023-11-03/blob/containers/create.go b/storage/2023-11-03/blob/containers/create.go index 98787fe..05f898b 100644 --- a/storage/2023-11-03/blob/containers/create.go +++ b/storage/2023-11-03/blob/containers/create.go @@ -1,9 +1,13 @@ package containers import ( + "bytes" "context" + "encoding/xml" "fmt" + "io" "net/http" + "strings" "github.com/hashicorp/go-azure-sdk/sdk/client" "github.com/hashicorp/go-azure-sdk/sdk/odata" @@ -26,7 +30,6 @@ type CreateInput struct { type CreateResponse struct { HttpResponse *http.Response - Error *ErrorResponse `xml:"Error"` } // Create creates a new container under the specified account. @@ -41,6 +44,30 @@ func (c Client) Create(ctx context.Context, containerName string, input CreateIn return } + // Retry the container creation if a conflicting container is still in the process of being deleted + retryFunc := func(resp *http.Response, _ *odata.OData) (bool, error) { + if resp != nil { + if resp.StatusCode == http.StatusConflict { + // TODO: move this error response parsing to a common helper function + respBody, err := io.ReadAll(resp.Body) + if err != nil { + return false, fmt.Errorf("could not parse response body") + } + resp.Body.Close() + respBody = bytes.TrimPrefix(respBody, []byte("\xef\xbb\xbf")) + res := ErrorResponse{} + if err = xml.Unmarshal(respBody, &res); err != nil { + return false, err + } + resp.Body = io.NopCloser(bytes.NewBuffer(respBody)) + if res.Code != nil { + return strings.Contains(*res.Code, "ContainerBeingDeleted"), nil + } + } + } + return false, nil + } + opts := client.RequestOptions{ ContentType: "application/xml; charset=utf-8", ExpectedStatusCodes: []int{ @@ -50,7 +77,8 @@ func (c Client) Create(ctx context.Context, containerName string, input CreateIn OptionsObject: createOptions{ input: input, }, - Path: fmt.Sprintf("/%s", containerName), + Path: fmt.Sprintf("/%s", containerName), + RetryFunc: retryFunc, } req, err := c.Client.NewRequest(ctx, opts) diff --git a/storage/2023-11-03/blob/containers/models.go b/storage/2023-11-03/blob/containers/models.go index c43a9e7..94c3b86 100644 --- a/storage/2023-11-03/blob/containers/models.go +++ b/storage/2023-11-03/blob/containers/models.go @@ -1,5 +1,7 @@ package containers +import "encoding/xml" + type AccessLevel string var ( @@ -41,8 +43,9 @@ var ( ) type ErrorResponse struct { - Code *string `xml:"Code"` - Message *string `xml:"Message"` + XMLName xml.Name `xml:"Error"` + Code *string `xml:"Code"` + Message *string `xml:"Message"` } type LeaseDuration string diff --git a/storage/2023-11-03/datalakestore/filesystems/client.go b/storage/2023-11-03/datalakestore/filesystems/client.go index 27e96d1..a121733 100644 --- a/storage/2023-11-03/datalakestore/filesystems/client.go +++ b/storage/2023-11-03/datalakestore/filesystems/client.go @@ -8,11 +8,11 @@ import ( // Client is the base client for Data Lake Store Filesystems. type Client struct { - Client *storage.BaseClient + Client *storage.Client } func NewWithBaseUri(baseUri string) (*Client, error) { - baseClient, err := storage.NewBaseClient(baseUri, componentName, apiVersion) + baseClient, err := storage.NewStorageClient(baseUri, componentName, apiVersion) if err != nil { return nil, fmt.Errorf("building base client: %+v", err) } diff --git a/storage/2023-11-03/datalakestore/paths/client.go b/storage/2023-11-03/datalakestore/paths/client.go index 27e70be..e0cb427 100644 --- a/storage/2023-11-03/datalakestore/paths/client.go +++ b/storage/2023-11-03/datalakestore/paths/client.go @@ -7,11 +7,11 @@ import ( // Client is the base client for Data Lake Storage Path type Client struct { - Client *storage.BaseClient + Client *storage.Client } func NewWithBaseUri(baseUri string) (*Client, error) { - baseClient, err := storage.NewBaseClient(baseUri, componentName, apiVersion) + baseClient, err := storage.NewStorageClient(baseUri, componentName, apiVersion) if err != nil { return nil, fmt.Errorf("building base client: %+v", err) } diff --git a/storage/2023-11-03/file/directories/client.go b/storage/2023-11-03/file/directories/client.go index 86f9fd1..7b327f0 100644 --- a/storage/2023-11-03/file/directories/client.go +++ b/storage/2023-11-03/file/directories/client.go @@ -8,11 +8,11 @@ import ( // Client is the base client for File Storage Shares. type Client struct { - Client *storage.BaseClient + Client *storage.Client } func NewWithBaseUri(baseUri string) (*Client, error) { - baseClient, err := storage.NewBaseClient(baseUri, componentName, apiVersion) + baseClient, err := storage.NewStorageClient(baseUri, componentName, apiVersion) if err != nil { return nil, fmt.Errorf("building base client: %+v", err) } diff --git a/storage/2023-11-03/file/files/client.go b/storage/2023-11-03/file/files/client.go index a875c77..cee19a3 100644 --- a/storage/2023-11-03/file/files/client.go +++ b/storage/2023-11-03/file/files/client.go @@ -8,11 +8,11 @@ import ( // Client is the base client for File Storage Shares. type Client struct { - Client *storage.BaseClient + Client *storage.Client } func NewWithBaseUri(baseUri string) (*Client, error) { - baseClient, err := storage.NewBaseClient(baseUri, componentName, apiVersion) + baseClient, err := storage.NewStorageClient(baseUri, componentName, apiVersion) if err != nil { return nil, fmt.Errorf("building base client: %+v", err) } diff --git a/storage/2023-11-03/file/files/range_get.go b/storage/2023-11-03/file/files/range_get.go index b605662..f8b40b8 100644 --- a/storage/2023-11-03/file/files/range_get.go +++ b/storage/2023-11-03/file/files/range_get.go @@ -3,7 +3,6 @@ package files import ( "context" "fmt" - "io" "net/http" "strings" @@ -18,8 +17,7 @@ type GetByteRangeInput struct { type GetByteRangeResponse struct { HttpResponse *http.Response - - Contents []byte + Contents *[]byte } // GetByteRange returns the specified Byte Range from the specified File. @@ -85,10 +83,12 @@ func (c Client) GetByteRange(ctx context.Context, shareName, path, fileName stri var resp *client.Response resp, err = req.Execute(ctx) if resp != nil { + result.Contents = &[]byte{} result.HttpResponse = resp.Response - if result.Contents, err = io.ReadAll(resp.Body); err != nil { - err = fmt.Errorf("reading response body: %+v", err) + err = resp.Unmarshal(result.Contents) + if err != nil { + err = fmt.Errorf("unmarshalling response: %+v", err) return } } 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 0858943..e923eb3 100644 --- a/storage/2023-11-03/file/files/range_get_file.go +++ b/storage/2023-11-03/file/files/range_get_file.go @@ -16,8 +16,7 @@ type GetFileInput struct { type GetFileResponse struct { HttpResponse *http.Response - - OutputBytes []byte + OutputBytes *[]byte } // GetFile is a helper method to download a file by chunking it automatically @@ -91,10 +90,10 @@ func (c Client) GetFile(ctx context.Context, shareName, path, fileName string, i // then finally put it all together, in order and return it output := make([]byte, length) for _, v := range results { - copy(output[v.startBytes:v.endBytes], v.bytes) + copy(output[v.startBytes:v.endBytes], *v.bytes) } - result.OutputBytes = output + *result.OutputBytes = output return } @@ -107,7 +106,7 @@ type downloadFileChunkInput struct { type downloadFileChunkResult struct { startBytes int64 endBytes int64 - bytes []byte + bytes *[]byte } func (c Client) downloadFileChunk(ctx context.Context, shareName, path, fileName string, input downloadFileChunkInput) (*downloadFileChunkResult, error) { diff --git a/storage/2023-11-03/file/files/range_get_file_test.go b/storage/2023-11-03/file/files/range_get_file_test.go index e7eb958..ea65a99 100644 --- a/storage/2023-11-03/file/files/range_get_file_test.go +++ b/storage/2023-11-03/file/files/range_get_file_test.go @@ -99,15 +99,16 @@ func testGetFile(t *testing.T, fileName string, contentType string) { t.Logf("[DEBUG] Asserting the files are the same size..") expectedBytes := make([]byte, info.Size()) file.Read(expectedBytes) - if len(expectedBytes) != len(resp.OutputBytes) { - t.Fatalf("Expected %d bytes but got %d", len(expectedBytes), len(resp.OutputBytes)) + outputBytes := *resp.OutputBytes + if len(expectedBytes) != len(*resp.OutputBytes) { + t.Fatalf("Expected %d bytes but got %d", len(expectedBytes), len(outputBytes)) } t.Logf("[DEBUG] Asserting the files are the same content-wise..") // overkill, but it's this or shasum-ing for i := int64(0); i < info.Size(); i++ { - if expectedBytes[i] != resp.OutputBytes[i] { - t.Fatalf("Expected byte %d to be %q but got %q", i, expectedBytes[i], resp.OutputBytes[i]) + if expectedBytes[i] != outputBytes[i] { + t.Fatalf("Expected byte %d to be %q but got %q", i, expectedBytes[i], outputBytes[i]) } } diff --git a/storage/2023-11-03/file/shares/acl_set.go b/storage/2023-11-03/file/shares/acl_set.go index 58e87bc..216d714 100644 --- a/storage/2023-11-03/file/shares/acl_set.go +++ b/storage/2023-11-03/file/shares/acl_set.go @@ -20,8 +20,7 @@ type SetAclResponse struct { type SetAclInput struct { SignedIdentifiers []SignedIdentifier `xml:"SignedIdentifier"` - - XMLName xml.Name `xml:"SignedIdentifiers"` + XMLName xml.Name `xml:"SignedIdentifiers"` } // SetACL sets the specified Access Control List on the specified Storage Share diff --git a/storage/2023-11-03/file/shares/client.go b/storage/2023-11-03/file/shares/client.go index 6e5fd15..7d6516f 100644 --- a/storage/2023-11-03/file/shares/client.go +++ b/storage/2023-11-03/file/shares/client.go @@ -8,11 +8,11 @@ import ( // Client is the base client for File Storage Shares. type Client struct { - Client *storage.BaseClient + Client *storage.Client } func NewWithBaseUri(baseUri string) (*Client, error) { - baseClient, err := storage.NewBaseClient(baseUri, componentName, apiVersion) + baseClient, err := storage.NewStorageClient(baseUri, componentName, apiVersion) if err != nil { return nil, fmt.Errorf("building base client: %+v", err) } diff --git a/storage/2023-11-03/file/shares/create.go b/storage/2023-11-03/file/shares/create.go index fdf13e3..32075f0 100644 --- a/storage/2023-11-03/file/shares/create.go +++ b/storage/2023-11-03/file/shares/create.go @@ -1,8 +1,11 @@ package shares import ( + "bytes" "context" + "encoding/xml" "fmt" + "io" "net/http" "strconv" "strings" @@ -62,6 +65,30 @@ func (c Client) Create(ctx context.Context, shareName string, input CreateInput) return } + // Retry the share creation if a conflicting share is still in the process of being deleted + retryFunc := func(resp *http.Response, _ *odata.OData) (bool, error) { + if resp != nil { + if resp.StatusCode == http.StatusConflict { + // TODO: move this error response parsing to a common helper function + respBody, err := io.ReadAll(resp.Body) + if err != nil { + return false, fmt.Errorf("could not parse response body") + } + resp.Body.Close() + respBody = bytes.TrimPrefix(respBody, []byte("\xef\xbb\xbf")) + res := ErrorResponse{} + if err = xml.Unmarshal(respBody, &res); err != nil { + return false, err + } + resp.Body = io.NopCloser(bytes.NewBuffer(respBody)) + if res.Code != nil { + return strings.Contains(*res.Code, "ShareBeingDeleted"), nil + } + } + } + return false, nil + } + opts := client.RequestOptions{ ContentType: "application/xml; charset=utf-8", ExpectedStatusCodes: []int{ @@ -71,7 +98,8 @@ func (c Client) Create(ctx context.Context, shareName string, input CreateInput) OptionsObject: CreateOptions{ input: input, }, - Path: fmt.Sprintf("/%s", shareName), + Path: fmt.Sprintf("/%s", shareName), + RetryFunc: retryFunc, } req, err := c.Client.NewRequest(ctx, opts) if err != nil { diff --git a/storage/2023-11-03/file/shares/models.go b/storage/2023-11-03/file/shares/models.go index 3272716..61c3be6 100644 --- a/storage/2023-11-03/file/shares/models.go +++ b/storage/2023-11-03/file/shares/models.go @@ -1,5 +1,7 @@ package shares +import "encoding/xml" + type SignedIdentifier struct { Id string `xml:"Id"` AccessPolicy AccessPolicy `xml:"AccessPolicy"` @@ -20,3 +22,9 @@ const ( // NFS indicates the share can be accessed by NFSv4.1. A premium account is required for this option. NFS ShareProtocol = "NFS" ) + +type ErrorResponse struct { + XMLName xml.Name `xml:"Error"` + Code *string `xml:"Code"` + Message *string `xml:"Message"` +} diff --git a/storage/2023-11-03/queue/messages/client.go b/storage/2023-11-03/queue/messages/client.go index ec5d64c..a3312a2 100644 --- a/storage/2023-11-03/queue/messages/client.go +++ b/storage/2023-11-03/queue/messages/client.go @@ -8,11 +8,11 @@ import ( // Client is the base client for Messages. type Client struct { - Client *storage.BaseClient + Client *storage.Client } func NewWithBaseUri(baseUri string) (*Client, error) { - baseClient, err := storage.NewBaseClient(baseUri, componentName, apiVersion) + baseClient, err := storage.NewStorageClient(baseUri, componentName, apiVersion) if err != nil { return nil, fmt.Errorf("building base client: %+v", err) } diff --git a/storage/2023-11-03/queue/queues/client.go b/storage/2023-11-03/queue/queues/client.go index 40aa674..4497f0e 100644 --- a/storage/2023-11-03/queue/queues/client.go +++ b/storage/2023-11-03/queue/queues/client.go @@ -10,11 +10,11 @@ import ( // Client is the base client for Messages. type Client struct { - Client *storage.BaseClient + Client *storage.Client } func NewWithBaseUri(baseUri string) (*Client, error) { - baseClient, err := storage.NewBaseClient(baseUri, componentName, apiVersion) + baseClient, err := storage.NewStorageClient(baseUri, componentName, apiVersion) if err != nil { return nil, fmt.Errorf("building base client: %+v", err) } diff --git a/storage/2023-11-03/table/entities/client.go b/storage/2023-11-03/table/entities/client.go index d1182ea..e190af6 100644 --- a/storage/2023-11-03/table/entities/client.go +++ b/storage/2023-11-03/table/entities/client.go @@ -8,11 +8,11 @@ import ( // Client is the base client for Table Storage Shares. type Client struct { - Client *storage.BaseClient + Client *storage.Client } func NewWithBaseUri(baseUri string) (*Client, error) { - baseClient, err := storage.NewBaseClient(baseUri, componentName, apiVersion) + baseClient, err := storage.NewStorageClient(baseUri, componentName, apiVersion) if err != nil { return nil, fmt.Errorf("building base client: %+v", err) } diff --git a/storage/2023-11-03/table/tables/client.go b/storage/2023-11-03/table/tables/client.go index 31e53c5..49c714d 100644 --- a/storage/2023-11-03/table/tables/client.go +++ b/storage/2023-11-03/table/tables/client.go @@ -8,11 +8,11 @@ import ( // Client is the base client for Table Storage Shares. type Client struct { - Client *storage.BaseClient + Client *storage.Client } func NewWithBaseUri(baseUri string) (*Client, error) { - baseClient, err := storage.NewBaseClient(baseUri, componentName, apiVersion) + baseClient, err := storage.NewStorageClient(baseUri, componentName, apiVersion) if err != nil { return nil, fmt.Errorf("building base client: %+v", err) } diff --git a/storage/internal/testhelpers/client.go b/storage/internal/testhelpers/client.go index 7116a9b..1d2321b 100644 --- a/storage/internal/testhelpers/client.go +++ b/storage/internal/testhelpers/client.go @@ -179,11 +179,11 @@ func (c Client) Configure(client *client.Client, authorizer auth.Authorizer) { // TODO: add logging } -func (c Client) PrepareWithResourceManagerAuth(input *storage.BaseClient) { +func (c Client) PrepareWithResourceManagerAuth(input *storage.Client) { input.SetAuthorizer(c.storageAuth) } -func (c Client) PrepareWithSharedKeyAuth(input *storage.BaseClient, data *TestResources, keyType auth.SharedKeyType) error { +func (c Client) PrepareWithSharedKeyAuth(input *storage.Client, data *TestResources, keyType auth.SharedKeyType) error { auth, err := auth.NewSharedKeyAuthorizer(data.StorageAccountName, data.StorageAccountKey, keyType) if err != nil { return fmt.Errorf("building SharedKey authorizer: %+v", err) From dfec5fd3b4274b2986acb01b8ccdb0c30c509f8a Mon Sep 17 00:00:00 2001 From: Tom Bamford Date: Fri, 23 Feb 2024 12:59:32 +0000 Subject: [PATCH 3/3] address review: use response helpers --- storage/2023-11-03/blob/containers/create.go | 3 ++- storage/2023-11-03/file/shares/create.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/storage/2023-11-03/blob/containers/create.go b/storage/2023-11-03/blob/containers/create.go index 05f898b..f47c4cf 100644 --- a/storage/2023-11-03/blob/containers/create.go +++ b/storage/2023-11-03/blob/containers/create.go @@ -9,6 +9,7 @@ import ( "net/http" "strings" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-sdk/sdk/client" "github.com/hashicorp/go-azure-sdk/sdk/odata" "github.com/tombuildsstuff/giovanni/storage/internal/metadata" @@ -47,7 +48,7 @@ func (c Client) Create(ctx context.Context, containerName string, input CreateIn // Retry the container creation if a conflicting container is still in the process of being deleted retryFunc := func(resp *http.Response, _ *odata.OData) (bool, error) { if resp != nil { - if resp.StatusCode == http.StatusConflict { + if response.WasStatusCode(resp, http.StatusConflict) { // TODO: move this error response parsing to a common helper function respBody, err := io.ReadAll(resp.Body) if err != nil { diff --git a/storage/2023-11-03/file/shares/create.go b/storage/2023-11-03/file/shares/create.go index 32075f0..46e8757 100644 --- a/storage/2023-11-03/file/shares/create.go +++ b/storage/2023-11-03/file/shares/create.go @@ -10,6 +10,7 @@ import ( "strconv" "strings" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-sdk/sdk/client" "github.com/hashicorp/go-azure-sdk/sdk/odata" "github.com/tombuildsstuff/giovanni/storage/internal/metadata" @@ -68,7 +69,7 @@ func (c Client) Create(ctx context.Context, shareName string, input CreateInput) // Retry the share creation if a conflicting share is still in the process of being deleted retryFunc := func(resp *http.Response, _ *odata.OData) (bool, error) { if resp != nil { - if resp.StatusCode == http.StatusConflict { + if response.WasStatusCode(resp, http.StatusConflict) { // TODO: move this error response parsing to a common helper function respBody, err := io.ReadAll(resp.Body) if err != nil {