Skip to content

Commit

Permalink
Merge pull request #104 from tombuildsstuff/f/unmarshalling-and-retries
Browse files Browse the repository at this point in the history
Improve unmarshalling and implement a RetryFunc
  • Loading branch information
manicminer authored Feb 24, 2024
2 parents b55c3a6 + dfec5fd commit a046cd9
Show file tree
Hide file tree
Showing 59 changed files with 191 additions and 116 deletions.
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
14 changes: 10 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
4 changes: 2 additions & 2 deletions storage/2020-08-04/blob/accounts/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion storage/2020-08-04/blob/blobs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
4 changes: 2 additions & 2 deletions storage/2020-08-04/blob/blobs/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion storage/2020-08-04/blob/containers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
4 changes: 2 additions & 2 deletions storage/2020-08-04/blob/containers/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion storage/2020-08-04/datalakestore/filesystems/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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{},
Expand Down
4 changes: 2 additions & 2 deletions storage/2020-08-04/datalakestore/filesystems/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions storage/2020-08-04/datalakestore/paths/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion storage/2020-08-04/file/directories/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
4 changes: 2 additions & 2 deletions storage/2020-08-04/file/directories/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion storage/2020-08-04/file/files/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down
4 changes: 2 additions & 2 deletions storage/2020-08-04/file/files/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion storage/2020-08-04/file/shares/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
4 changes: 2 additions & 2 deletions storage/2020-08-04/file/shares/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion storage/2020-08-04/queue/messages/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
4 changes: 2 additions & 2 deletions storage/2020-08-04/queue/messages/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion storage/2020-08-04/queue/queues/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
4 changes: 2 additions & 2 deletions storage/2020-08-04/queue/queues/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion storage/2020-08-04/table/entities/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
4 changes: 2 additions & 2 deletions storage/2020-08-04/table/entities/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion storage/2020-08-04/table/tables/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions storage/2020-08-04/table/tables/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions storage/2023-11-03/blob/accounts/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion storage/2023-11-03/blob/blobs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
10 changes: 4 additions & 6 deletions storage/2023-11-03/blob/blobs/append_block.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package blobs

import (
"bytes"
"context"
"fmt"
"io"
"net/http"
"strconv"
"strings"
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions storage/2023-11-03/blob/blobs/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
5 changes: 3 additions & 2 deletions storage/2023-11-03/blob/blobs/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit a046cd9

Please sign in to comment.