diff --git a/go.mod b/go.mod index 4ed4385552b1..cb951b3a6f1c 100644 --- a/go.mod +++ b/go.mod @@ -93,4 +93,5 @@ require ( go 1.21 -replace github.com/hashicorp/go-azure-sdk/sdk => /Users/tom/git/hashicorp/go-azure-sdk/sdk \ No newline at end of file +replace github.com/hashicorp/go-azure-sdk/sdk => /Users/tom/git/hashicorp/go-azure-sdk/sdk +replace github.com/tombuildsstuff/giovanni => /Users/tom/git/tombuildsstuff/giovanni diff --git a/internal/services/arckubernetes/arc_kubernetes_flux_configuration_resource.go b/internal/services/arckubernetes/arc_kubernetes_flux_configuration_resource.go index ccdac918aa82..5ec30309b0e5 100644 --- a/internal/services/arckubernetes/arc_kubernetes_flux_configuration_resource.go +++ b/internal/services/arckubernetes/arc_kubernetes_flux_configuration_resource.go @@ -239,7 +239,7 @@ func (r ArcKubernetesFluxConfigurationResource) Arguments() map[string]*pluginsd "container_id": { Type: pluginsdk.TypeString, Required: true, - ValidateFunc: storageValidate.StorageContainerDataPlaneID, + ValidateFunc: storageValidate.StorageContainerDataPlaneIDForDomainSuffix(""), // TODO need to know the storage domain suffix at schema time! }, "account_key": { @@ -570,7 +570,7 @@ func (r ArcKubernetesFluxConfigurationResource) Create() sdk.ResourceFunc { properties.Properties.Bucket, properties.Properties.ConfigurationProtectedSettings = expandBucketDefinitionModel(model.Bucket) } else if _, exists = metadata.ResourceData.GetOk("blob_storage"); exists { properties.Properties.SourceKind = pointer.To(fluxconfiguration.SourceKindTypeAzureBlob) - azureBlob, err := expandArcAzureBlobDefinitionModel(model.BlobStorage) + azureBlob, err := expandArcAzureBlobDefinitionModel(model.BlobStorage, metadata.Client.Storage.StorageDomainSuffix) if err != nil { return fmt.Errorf("expanding `blob_storage`: %+v", err) } @@ -624,7 +624,7 @@ func (r ArcKubernetesFluxConfigurationResource) Update() sdk.ResourceFunc { properties.Properties.ConfigurationProtectedSettings = nil if metadata.ResourceData.HasChange("blob_storage") { - azureBlob, err := expandArcAzureBlobDefinitionModel(model.BlobStorage) + azureBlob, err := expandArcAzureBlobDefinitionModel(model.BlobStorage, metadata.Client.Storage.StorageDomainSuffix) if err != nil { return fmt.Errorf("expanding `blob_storage`: %+v", err) } @@ -717,7 +717,7 @@ func (r ArcKubernetesFluxConfigurationResource) Read() sdk.ResourceFunc { if model := resp.Model; model != nil { if properties := model.Properties; properties != nil { - blobStorage, err := flattenArcAzureBlobDefinitionModel(properties.AzureBlob, configModel.BlobStorage) + blobStorage, err := flattenArcAzureBlobDefinitionModel(properties.AzureBlob, configModel.BlobStorage, metadata.Client.Storage.StorageDomainSuffix) if err != nil { return fmt.Errorf("flattening `blob_storage`: %+v", err) } @@ -762,7 +762,7 @@ func (r ArcKubernetesFluxConfigurationResource) Delete() sdk.ResourceFunc { } } -func expandArcAzureBlobDefinitionModel(inputList []AzureBlobDefinitionModel) (*fluxconfiguration.AzureBlobDefinition, error) { +func expandArcAzureBlobDefinitionModel(inputList []AzureBlobDefinitionModel, storageDomainSuffix string) (*fluxconfiguration.AzureBlobDefinition, error) { if len(inputList) == 0 { return nil, nil } @@ -778,7 +778,7 @@ func expandArcAzureBlobDefinitionModel(inputList []AzureBlobDefinitionModel) (*f } if input.ContainerID != "" { - id, err := parse.StorageContainerDataPlaneID(input.ContainerID) + id, err := parse.StorageContainerDataPlaneID(input.ContainerID, storageDomainSuffix) if err != nil { return nil, err } @@ -969,13 +969,13 @@ func expandRepositoryRefDefinitionModel(referenceType string, referenceValue str return &output, nil } -func flattenArcAzureBlobDefinitionModel(input *fluxconfiguration.AzureBlobDefinition, azureBlob []AzureBlobDefinitionModel) ([]AzureBlobDefinitionModel, error) { +func flattenArcAzureBlobDefinitionModel(input *fluxconfiguration.AzureBlobDefinition, azureBlob []AzureBlobDefinitionModel, storageDomainSuffix string) ([]AzureBlobDefinitionModel, error) { outputList := make([]AzureBlobDefinitionModel, 0) if input == nil { return outputList, nil } - id, err := parse.StorageContainerDataPlaneID(fmt.Sprintf("%s/%s", pointer.From(input.Url), pointer.From(input.ContainerName))) + id, err := parse.StorageContainerDataPlaneID(fmt.Sprintf("%s/%s", pointer.From(input.Url), pointer.From(input.ContainerName)), storageDomainSuffix) if err != nil { return nil, err } diff --git a/internal/services/containers/kubernetes_flux_configuration_resource.go b/internal/services/containers/kubernetes_flux_configuration_resource.go index d5b25970cdf8..2fb11f833b1f 100644 --- a/internal/services/containers/kubernetes_flux_configuration_resource.go +++ b/internal/services/containers/kubernetes_flux_configuration_resource.go @@ -244,7 +244,7 @@ func (r KubernetesFluxConfigurationResource) Arguments() map[string]*pluginsdk.S "container_id": { Type: pluginsdk.TypeString, Required: true, - ValidateFunc: storageValidate.StorageContainerDataPlaneID, + ValidateFunc: storageValidate.StorageContainerDataPlaneIDForDomainSuffix(""), // TODO need to know the storage domain suffix at schema time! }, "account_key": { @@ -589,7 +589,7 @@ func (r KubernetesFluxConfigurationResource) Create() sdk.ResourceFunc { properties.Properties.Bucket, properties.Properties.ConfigurationProtectedSettings = expandBucketDefinitionModel(model.Bucket) } else if _, exists = metadata.ResourceData.GetOk("blob_storage"); exists { properties.Properties.SourceKind = pointer.To(fluxconfiguration.SourceKindTypeAzureBlob) - azureBlob, err := expandAzureBlobDefinitionModel(model.BlobStorage) + azureBlob, err := expandAzureBlobDefinitionModel(model.BlobStorage, metadata.Client.Storage.StorageDomainSuffix) if err != nil { return fmt.Errorf("expanding `blob_storage`: %+v", err) } @@ -643,7 +643,7 @@ func (r KubernetesFluxConfigurationResource) Update() sdk.ResourceFunc { properties.Properties.ConfigurationProtectedSettings = nil if metadata.ResourceData.HasChange("blob_storage") { - azureBlob, err := expandAzureBlobDefinitionModel(model.BlobStorage) + azureBlob, err := expandAzureBlobDefinitionModel(model.BlobStorage, metadata.Client.Storage.StorageDomainSuffix) if err != nil { return fmt.Errorf("expanding `blob_storage`: %+v", err) } @@ -735,7 +735,7 @@ func (r KubernetesFluxConfigurationResource) Read() sdk.ResourceFunc { if model := resp.Model; model != nil { if properties := model.Properties; properties != nil { - blobStorage, err := flattenAzureBlobDefinitionModel(properties.AzureBlob, configModel.BlobStorage) + blobStorage, err := flattenAzureBlobDefinitionModel(properties.AzureBlob, configModel.BlobStorage, metadata.Client.Storage.StorageDomainSuffix) if err != nil { return fmt.Errorf("flattening `blob_storage`: %+v", err) } @@ -780,7 +780,7 @@ func (r KubernetesFluxConfigurationResource) Delete() sdk.ResourceFunc { } } -func expandAzureBlobDefinitionModel(inputList []AzureBlobDefinitionModel) (*fluxconfiguration.AzureBlobDefinition, error) { +func expandAzureBlobDefinitionModel(inputList []AzureBlobDefinitionModel, storageDomainSuffix string) (*fluxconfiguration.AzureBlobDefinition, error) { if len(inputList) == 0 { return nil, nil } @@ -797,7 +797,7 @@ func expandAzureBlobDefinitionModel(inputList []AzureBlobDefinitionModel) (*flux } if input.ContainerID != "" { - id, err := parse.StorageContainerDataPlaneID(input.ContainerID) + id, err := parse.StorageContainerDataPlaneID(input.ContainerID, storageDomainSuffix) if err != nil { return nil, err } @@ -1002,13 +1002,13 @@ func expandRepositoryRefDefinitionModel(referenceType string, referenceValue str return &output, nil } -func flattenAzureBlobDefinitionModel(input *fluxconfiguration.AzureBlobDefinition, azureBlob []AzureBlobDefinitionModel) ([]AzureBlobDefinitionModel, error) { +func flattenAzureBlobDefinitionModel(input *fluxconfiguration.AzureBlobDefinition, azureBlob []AzureBlobDefinitionModel, storageDomainSuffix string) ([]AzureBlobDefinitionModel, error) { outputList := make([]AzureBlobDefinitionModel, 0) if input == nil { return outputList, nil } - id, err := parse.StorageContainerDataPlaneID(fmt.Sprintf("%s/%s", pointer.From(input.Url), pointer.From(input.ContainerName))) + id, err := parse.StorageContainerDataPlaneID(fmt.Sprintf("%s/%s", pointer.From(input.Url), pointer.From(input.ContainerName)), storageDomainSuffix) if err != nil { return nil, err } diff --git a/internal/services/legacy/virtual_machine_resource.go b/internal/services/legacy/virtual_machine_resource.go index e1d7d72e3e37..f67dbc20afc9 100644 --- a/internal/services/legacy/virtual_machine_resource.go +++ b/internal/services/legacy/virtual_machine_resource.go @@ -30,7 +30,7 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" "github.com/hashicorp/terraform-provider-azurerm/internal/timeouts" "github.com/hashicorp/terraform-provider-azurerm/utils" - "github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs" + "github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs" "github.com/tombuildsstuff/kermit/sdk/compute/2023-03-01/compute" "github.com/tombuildsstuff/kermit/sdk/network/2022-07-01/network" ) @@ -1033,24 +1033,24 @@ func resourceVirtualMachineDeleteVhd(ctx context.Context, storageClient *intStor } uri := *vhd.URI - id, err := blobs.ParseResourceID(uri) + id, err := blobs.ParseBlobID(uri, storageClient.StorageDomainSuffix) if err != nil { return fmt.Errorf("parsing %q: %s", uri, err) } - account, err := storageClient.FindAccount(ctx, id.AccountName) + account, err := storageClient.FindAccount(ctx, id.AccountId.AccountName) if err != nil { - return fmt.Errorf("retrieving Account %q for Blob %q (Container %q): %s", id.AccountName, id.BlobName, id.ContainerName, err) + return fmt.Errorf("retrieving Account %q for Blob %q (Container %q): %s", id.AccountId.AccountName, id.BlobName, id.ContainerName, err) } if account == nil { - return fmt.Errorf("Unable to locate Storage Account %q (Disk %q)!", id.AccountName, uri) + return fmt.Errorf("Unable to locate Storage Account %q (Disk %q)!", id.AccountId.AccountName, uri) } if err != nil { return fmt.Errorf("building Blobs Client: %s", err) } - blobsClient, err := storageClient.BlobsClient(ctx, *account) + blobsClient, err := storageClient.BlobsDataPlaneClient(ctx, *account) if err != nil { return fmt.Errorf("building Blobs Client: %s", err) } @@ -1058,8 +1058,8 @@ func resourceVirtualMachineDeleteVhd(ctx context.Context, storageClient *intStor input := blobs.DeleteInput{ DeleteSnapshots: false, } - if _, err := blobsClient.Delete(ctx, id.AccountName, id.ContainerName, id.BlobName, input); err != nil { - return fmt.Errorf("deleting Blob %q (Container %q / Account %q / Resource Group %q): %s", id.BlobName, id.ContainerName, id.AccountName, account.ResourceGroup, err) + if _, err := blobsClient.Delete(ctx, id.ContainerName, id.BlobName, input); err != nil { + return fmt.Errorf("deleting Blob %q (Container %q / Account %q / Resource Group %q): %s", id.BlobName, id.ContainerName, id.AccountId.AccountName, account.ResourceGroup, err) } return nil diff --git a/internal/services/legacy/virtual_machine_resource_test.go b/internal/services/legacy/virtual_machine_resource_test.go index 656633a55ee0..2a8411f4f5af 100644 --- a/internal/services/legacy/virtual_machine_resource_test.go +++ b/internal/services/legacy/virtual_machine_resource_test.go @@ -249,7 +249,7 @@ func (VirtualMachineResource) unmanagedDiskExistsInContainer(blobName string, sh return fmt.Errorf("Unable to locate Storage Account %q!", accountName) } - client, err := clients.Storage.BlobsClient(ctx, *account) + client, err := clients.Storage.BlobsDataPlaneClient(ctx, *account) if err != nil { return fmt.Errorf("building Blobs Client: %s", err) } diff --git a/internal/services/storage/client/client.go b/internal/services/storage/client/client.go index d64b28677eeb..bcd5750ee690 100644 --- a/internal/services/storage/client/client.go +++ b/internal/services/storage/client/client.go @@ -4,11 +4,9 @@ package client import ( - "context" "fmt" "github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2021-09-01/storage" // nolint: staticcheck - "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" storage_v2023_01_01 "github.com/hashicorp/go-azure-sdk/resource-manager/storage/2023-01-01" "github.com/hashicorp/go-azure-sdk/resource-manager/storagesync/2020-03-01/cloudendpointresource" @@ -16,20 +14,9 @@ import ( "github.com/hashicorp/go-azure-sdk/resource-manager/storagesync/2020-03-01/syncgroupresource" "github.com/hashicorp/go-azure-sdk/sdk/auth" "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" - "github.com/hashicorp/go-azure-sdk/sdk/environments" "github.com/hashicorp/terraform-provider-azurerm/internal/common" - "github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/shim" - "github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts" - "github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs" - "github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers" "github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems" "github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/paths" - "github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories" - "github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files" - "github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares" - "github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues" - "github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities" - "github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables" ) type Client struct { @@ -48,13 +35,10 @@ type Client struct { ResourceManager *storage_v2023_01_01.Client - Environment environments.Environment AzureEnvironment azure.Environment StorageDomainSuffix string - resourceManagerAuthorizer autorest.Authorizer - authorizerForAad auth.Authorizer - autorestAuthorizerForAad *autorest.Authorizer + authorizerForAad auth.Authorizer } func NewClient(o *common.ClientOptions) (*Client, error) { @@ -130,305 +114,13 @@ func NewClient(o *common.ClientOptions) (*Client, error) { SyncServiceClient: syncServiceClient, SyncGroupsClient: syncGroupsClient, - Environment: o.Environment, AzureEnvironment: o.AzureEnvironment, StorageDomainSuffix: *storageSuffix, - - resourceManagerAuthorizer: o.ResourceManagerAuthorizer, } if o.StorageUseAzureAD { client.authorizerForAad = o.Authorizers.Storage - client.autorestAuthorizerForAad = &o.StorageAuthorizer } return &client, nil } - -func (client Client) AccountsDataPlaneClient(ctx context.Context, account accountDetails) (*accounts.Client, error) { - if client.authorizerForAad != nil { - accountsClient, err := accounts.NewWithBaseUri(client.StorageDomainSuffix) - if err != nil { - return nil, fmt.Errorf("building Blob Storage Accounts client: %+v", err) - } - - accountsClient.Client.SetAuthorizer(client.authorizerForAad) - - return accountsClient, nil - } - - accountKey, err := account.AccountKey(ctx, client) - if err != nil { - return nil, fmt.Errorf("retrieving Storage Account Key: %s", err) - } - - storageAuth, err := auth.NewSharedKeyAuthorizer(account.name, *accountKey, auth.SharedKey) - if err != nil { - return nil, fmt.Errorf("building Shared Key Authorizer for Blob Storage client: %+v", err) - } - - accountsClient, err := accounts.NewWithBaseUri(client.StorageDomainSuffix) - if err != nil { - return nil, fmt.Errorf("building Blob Storage Accounts client: %+v", err) - } - - accountsClient.Client.SetAuthorizer(storageAuth) - - return accountsClient, nil -} - -func (client Client) BlobsClient(ctx context.Context, account accountDetails) (*blobs.Client, error) { - if client.authorizerForAad != nil { - blobsClient, err := blobs.NewWithBaseUri(client.StorageDomainSuffix) - if err != nil { - return nil, fmt.Errorf("building Blob Storage Blobs client: %+v", err) - } - - blobsClient.Client.SetAuthorizer(client.authorizerForAad) - - return blobsClient, nil - } - - accountKey, err := account.AccountKey(ctx, client) - if err != nil { - return nil, fmt.Errorf("retrieving Storage Account Key: %s", err) - } - - storageAuth, err := auth.NewSharedKeyAuthorizer(account.name, *accountKey, auth.SharedKey) - if err != nil { - return nil, fmt.Errorf("building Shared Key Authorizer for Blob Storage client: %+v", err) - } - - blobsClient, err := blobs.NewWithBaseUri(client.StorageDomainSuffix) - if err != nil { - return nil, fmt.Errorf("building Blob Storage Blobs client: %+v", err) - } - - blobsClient.Client.SetAuthorizer(storageAuth) - - return blobsClient, nil -} - -func (client Client) ContainersClient(ctx context.Context, account accountDetails) (shim.StorageContainerWrapper, error) { - if client.authorizerForAad != nil { - containersClient, err := containers.NewWithBaseUri(client.StorageDomainSuffix) - if err != nil { - return nil, fmt.Errorf("building Blob Storage Containers client: %+v", err) - } - - containersClient.Client.SetAuthorizer(client.authorizerForAad) - - return shim.NewDataPlaneStorageContainerWrapper(containersClient), nil - } - - accountKey, err := account.AccountKey(ctx, client) - if err != nil { - return nil, fmt.Errorf("retrieving Storage Account Key: %s", err) - } - - storageAuth, err := auth.NewSharedKeyAuthorizer(account.name, *accountKey, auth.SharedKey) - if err != nil { - return nil, fmt.Errorf("building Shared Key Authorizer for Blob Storage client: %+v", err) - } - - containersClient, err := containers.NewWithBaseUri(client.StorageDomainSuffix) - if err != nil { - return nil, fmt.Errorf("building Blob Storage Containers client: %+v", err) - } - - containersClient.Client.SetAuthorizer(storageAuth) - - return shim.NewDataPlaneStorageContainerWrapper(containersClient), nil -} - -func (client Client) FileShareDirectoriesClient(ctx context.Context, account accountDetails) (*directories.Client, error) { - if client.authorizerForAad != nil { - directoriesClient, err := directories.NewWithBaseUri(client.StorageDomainSuffix) - if err != nil { - return nil, fmt.Errorf("building File Storage Share Directories client: %+v", err) - } - - directoriesClient.Client.SetAuthorizer(client.authorizerForAad) - - return directoriesClient, nil - } - - accountKey, err := account.AccountKey(ctx, client) - if err != nil { - return nil, fmt.Errorf("retrieving Storage Account Key: %s", err) - } - - storageAuth, err := auth.NewSharedKeyAuthorizer(account.name, *accountKey, auth.SharedKey) - if err != nil { - return nil, fmt.Errorf("building Shared Key Authorizer for File Storage Shares client: %+v", err) - } - - directoriesClient, err := directories.NewWithBaseUri(client.StorageDomainSuffix) - if err != nil { - return nil, fmt.Errorf("building File Storage Share Directories client: %+v", err) - } - - directoriesClient.Client.SetAuthorizer(storageAuth) - - return directoriesClient, nil -} - -func (client Client) FileShareFilesClient(ctx context.Context, account accountDetails) (*files.Client, error) { - if client.authorizerForAad != nil { - filesClient, err := files.NewWithBaseUri(client.StorageDomainSuffix) - if err != nil { - return nil, fmt.Errorf("building File Storage Share Files client: %+v", err) - } - - filesClient.Client.SetAuthorizer(client.authorizerForAad) - - return filesClient, nil - } - - accountKey, err := account.AccountKey(ctx, client) - if err != nil { - return nil, fmt.Errorf("retrieving Storage Account Key: %s", err) - } - - storageAuth, err := auth.NewSharedKeyAuthorizer(account.name, *accountKey, auth.SharedKey) - if err != nil { - return nil, fmt.Errorf("building Shared Key Authorizer for File Storage Shares client: %+v", err) - } - - filesClient, err := files.NewWithBaseUri(client.StorageDomainSuffix) - if err != nil { - return nil, fmt.Errorf("building File Storage Share Files client: %+v", err) - } - - filesClient.Client.SetAuthorizer(storageAuth) - - return filesClient, nil -} - -func (client Client) FileSharesClient(ctx context.Context, account accountDetails) (shim.StorageShareWrapper, error) { - if client.authorizerForAad != nil { - sharesClient, err := shares.NewWithBaseUri(client.StorageDomainSuffix) - if err != nil { - return nil, fmt.Errorf("building File Storage Share Shares client: %+v", err) - } - - sharesClient.Client.SetAuthorizer(client.authorizerForAad) - - return shim.NewDataPlaneStorageShareWrapper(sharesClient), nil - } - - accountKey, err := account.AccountKey(ctx, client) - if err != nil { - return nil, fmt.Errorf("retrieving Storage Account Key: %s", err) - } - - storageAuth, err := auth.NewSharedKeyAuthorizer(account.name, *accountKey, auth.SharedKey) - if err != nil { - return nil, fmt.Errorf("building Shared Key Authorizer for File Storage Shares client: %+v", err) - } - - sharesClient, err := shares.NewWithBaseUri(client.StorageDomainSuffix) - if err != nil { - return nil, fmt.Errorf("building File Storage Share Shares client: %+v", err) - } - - sharesClient.Client.SetAuthorizer(storageAuth) - - return shim.NewDataPlaneStorageShareWrapper(sharesClient), nil -} - -func (client Client) QueuesClient(ctx context.Context, account accountDetails) (shim.StorageQueuesWrapper, error) { - if client.authorizerForAad != nil { - queuesClient, err := queues.NewWithBaseUri(client.StorageDomainSuffix) - if err != nil { - return nil, fmt.Errorf("building File Storage Queue Queues client: %+v", err) - } - - queuesClient.Client.SetAuthorizer(client.authorizerForAad) - - return shim.NewDataPlaneStorageQueueWrapper(queuesClient), nil - } - - accountKey, err := account.AccountKey(ctx, client) - if err != nil { - return nil, fmt.Errorf("retrieving Storage Account Key: %s", err) - } - - storageAuth, err := auth.NewSharedKeyAuthorizer(account.name, *accountKey, auth.SharedKey) - if err != nil { - return nil, fmt.Errorf("building Queued Key Authorizer for File Storage Queues client: %+v", err) - } - - queuesClient, err := queues.NewWithBaseUri(client.StorageDomainSuffix) - if err != nil { - return nil, fmt.Errorf("building File Storage Queue Queues client: %+v", err) - } - - queuesClient.Client.SetAuthorizer(storageAuth) - - return shim.NewDataPlaneStorageQueueWrapper(queuesClient), nil -} - -func (client Client) TableEntityClient(ctx context.Context, account accountDetails) (*entities.Client, error) { - if client.authorizerForAad != nil { - entitiesClient, err := entities.NewWithBaseUri(client.StorageDomainSuffix) - if err != nil { - return nil, fmt.Errorf("building Table Storage Share Entities client: %+v", err) - } - - entitiesClient.Client.SetAuthorizer(client.authorizerForAad) - - return entitiesClient, nil - } - - accountKey, err := account.AccountKey(ctx, client) - if err != nil { - return nil, fmt.Errorf("retrieving Storage Account Key: %s", err) - } - - storageAuth, err := auth.NewSharedKeyAuthorizer(account.name, *accountKey, auth.SharedKey) - if err != nil { - return nil, fmt.Errorf("building Shared Key Authorizer for Table Storage Shares client: %+v", err) - } - - entitiesClient, err := entities.NewWithBaseUri(client.StorageDomainSuffix) - if err != nil { - return nil, fmt.Errorf("building Table Storage Share Entities client: %+v", err) - } - - entitiesClient.Client.SetAuthorizer(storageAuth) - - return entitiesClient, nil -} - -func (client Client) TablesClient(ctx context.Context, account accountDetails) (shim.StorageTableWrapper, error) { - if client.authorizerForAad != nil { - tablesClient, err := tables.NewWithBaseUri(client.StorageDomainSuffix) - if err != nil { - return nil, fmt.Errorf("building Table Storage Share Tables client: %+v", err) - } - - tablesClient.Client.SetAuthorizer(client.authorizerForAad) - - return shim.NewDataPlaneStorageTableWrapper(tablesClient), nil - } - - accountKey, err := account.AccountKey(ctx, client) - if err != nil { - return nil, fmt.Errorf("retrieving Storage Account Key: %s", err) - } - - storageAuth, err := auth.NewSharedKeyAuthorizer(account.name, *accountKey, auth.SharedKey) - if err != nil { - return nil, fmt.Errorf("building Shared Key Authorizer for Table Storage Shares client: %+v", err) - } - - tablesClient, err := tables.NewWithBaseUri(client.StorageDomainSuffix) - if err != nil { - return nil, fmt.Errorf("building Table Storage Share Tables client: %+v", err) - } - - tablesClient.Client.SetAuthorizer(storageAuth) - - return shim.NewDataPlaneStorageTableWrapper(tablesClient), nil -} diff --git a/internal/services/storage/client/data_plane.go b/internal/services/storage/client/data_plane.go new file mode 100644 index 000000000000..75575a7ff249 --- /dev/null +++ b/internal/services/storage/client/data_plane.go @@ -0,0 +1,415 @@ +package client + +import ( + "context" + "fmt" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/auth" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/shim" + "github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts" + "github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs" + "github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers" + "github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories" + "github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files" + "github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares" + "github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues" + "github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities" + "github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables" +) + +func (client Client) AccountsDataPlaneClient(ctx context.Context, account accountDetails) (*accounts.Client, error) { + if account.Properties == nil { + return nil, fmt.Errorf("storage account %q has no properties", account.name) + } + if account.Properties.PrimaryEndpoints == nil { + return nil, fmt.Errorf("storage account %q has missing endpoints", account.name) + } + if account.Properties.PrimaryEndpoints.Blob == nil { + return nil, fmt.Errorf("determing Blob endpoint for storage account %q", account.name) + } + + baseUri := strings.TrimSuffix(*account.Properties.PrimaryEndpoints.Blob, "/") + + if client.authorizerForAad != nil { + accountsClient, err := accounts.NewWithBaseUri(baseUri) + if err != nil { + return nil, fmt.Errorf("building Blob Storage Accounts client: %+v", err) + } + + accountsClient.Client.SetAuthorizer(client.authorizerForAad) + + return accountsClient, nil + } + + accountKey, err := account.AccountKey(ctx, client) + if err != nil { + return nil, fmt.Errorf("retrieving Storage Account Key: %s", err) + } + + storageAuth, err := auth.NewSharedKeyAuthorizer(account.name, *accountKey, auth.SharedKey) + if err != nil { + return nil, fmt.Errorf("building Shared Key Authorizer for Blob Storage client: %+v", err) + } + + accountsClient, err := accounts.NewWithBaseUri(baseUri) + if err != nil { + return nil, fmt.Errorf("building Blob Storage Accounts client: %+v", err) + } + + accountsClient.Client.SetAuthorizer(storageAuth) + + return accountsClient, nil +} + +func (client Client) BlobsDataPlaneClient(ctx context.Context, account accountDetails) (*blobs.Client, error) { + if account.Properties == nil { + return nil, fmt.Errorf("storage account %q has no properties", account.name) + } + if account.Properties.PrimaryEndpoints == nil { + return nil, fmt.Errorf("storage account %q has missing endpoints", account.name) + } + if account.Properties.PrimaryEndpoints.Blob == nil { + return nil, fmt.Errorf("determing Blob endpoint for storage account %q", account.name) + } + + baseUri := strings.TrimSuffix(*account.Properties.PrimaryEndpoints.Blob, "/") + + if client.authorizerForAad != nil { + blobsClient, err := blobs.NewWithBaseUri(baseUri) + if err != nil { + return nil, fmt.Errorf("building Blob Storage Blobs client: %+v", err) + } + + blobsClient.Client.SetAuthorizer(client.authorizerForAad) + + return blobsClient, nil + } + + accountKey, err := account.AccountKey(ctx, client) + if err != nil { + return nil, fmt.Errorf("retrieving Storage Account Key: %s", err) + } + + storageAuth, err := auth.NewSharedKeyAuthorizer(account.name, *accountKey, auth.SharedKey) + if err != nil { + return nil, fmt.Errorf("building Shared Key Authorizer for Blob Storage client: %+v", err) + } + + blobsClient, err := blobs.NewWithBaseUri(baseUri) + if err != nil { + return nil, fmt.Errorf("building Blob Storage Blobs client: %+v", err) + } + + blobsClient.Client.SetAuthorizer(storageAuth) + + return blobsClient, nil +} + +func (client Client) ContainersDataPlaneClient(ctx context.Context, account accountDetails) (shim.StorageContainerWrapper, error) { + if account.Properties == nil { + return nil, fmt.Errorf("storage account %q has no properties", account.name) + } + if account.Properties.PrimaryEndpoints == nil { + return nil, fmt.Errorf("storage account %q has missing endpoints", account.name) + } + if account.Properties.PrimaryEndpoints.Blob == nil { + return nil, fmt.Errorf("determing Blob endpoint for storage account %q", account.name) + } + + baseUri := strings.TrimSuffix(*account.Properties.PrimaryEndpoints.Blob, "/") + + if client.authorizerForAad != nil { + containersClient, err := containers.NewWithBaseUri(baseUri) + if err != nil { + return nil, fmt.Errorf("building Blob Storage Containers client: %+v", err) + } + + containersClient.Client.SetAuthorizer(client.authorizerForAad) + + return shim.NewDataPlaneStorageContainerWrapper(containersClient), nil + } + + accountKey, err := account.AccountKey(ctx, client) + if err != nil { + return nil, fmt.Errorf("retrieving Storage Account Key: %s", err) + } + + storageAuth, err := auth.NewSharedKeyAuthorizer(account.name, *accountKey, auth.SharedKey) + if err != nil { + return nil, fmt.Errorf("building Shared Key Authorizer for Blob Storage client: %+v", err) + } + + containersClient, err := containers.NewWithBaseUri(baseUri) + if err != nil { + return nil, fmt.Errorf("building Blob Storage Containers client: %+v", err) + } + + containersClient.Client.SetAuthorizer(storageAuth) + + return shim.NewDataPlaneStorageContainerWrapper(containersClient), nil +} + +func (client Client) FileShareDirectoriesDataPlaneClient(ctx context.Context, account accountDetails) (*directories.Client, error) { + if account.Properties == nil { + return nil, fmt.Errorf("storage account %q has no properties", account.name) + } + if account.Properties.PrimaryEndpoints == nil { + return nil, fmt.Errorf("storage account %q has missing endpoints", account.name) + } + if account.Properties.PrimaryEndpoints.File == nil { + return nil, fmt.Errorf("determing File endpoint for storage account %q", account.name) + } + + baseUri := strings.TrimSuffix(*account.Properties.PrimaryEndpoints.File, "/") + + if client.authorizerForAad != nil { + directoriesClient, err := directories.NewWithBaseUri(baseUri) + if err != nil { + return nil, fmt.Errorf("building File Storage Share Directories client: %+v", err) + } + + directoriesClient.Client.SetAuthorizer(client.authorizerForAad) + + return directoriesClient, nil + } + + accountKey, err := account.AccountKey(ctx, client) + if err != nil { + return nil, fmt.Errorf("retrieving Storage Account Key: %s", err) + } + + storageAuth, err := auth.NewSharedKeyAuthorizer(account.name, *accountKey, auth.SharedKey) + if err != nil { + return nil, fmt.Errorf("building Shared Key Authorizer for File Storage Shares client: %+v", err) + } + + directoriesClient, err := directories.NewWithBaseUri(baseUri) + if err != nil { + return nil, fmt.Errorf("building File Storage Share Directories client: %+v", err) + } + + directoriesClient.Client.SetAuthorizer(storageAuth) + + return directoriesClient, nil +} + +func (client Client) FileShareFilesDataPlaneClient(ctx context.Context, account accountDetails) (*files.Client, error) { + if account.Properties == nil { + return nil, fmt.Errorf("storage account %q has no properties", account.name) + } + if account.Properties.PrimaryEndpoints == nil { + return nil, fmt.Errorf("storage account %q has missing endpoints", account.name) + } + if account.Properties.PrimaryEndpoints.File == nil { + return nil, fmt.Errorf("determing File endpoint for storage account %q", account.name) + } + + baseUri := strings.TrimSuffix(*account.Properties.PrimaryEndpoints.File, "/") + + if client.authorizerForAad != nil { + filesClient, err := files.NewWithBaseUri(baseUri) + if err != nil { + return nil, fmt.Errorf("building File Storage Share Files client: %+v", err) + } + + filesClient.Client.SetAuthorizer(client.authorizerForAad) + + return filesClient, nil + } + + accountKey, err := account.AccountKey(ctx, client) + if err != nil { + return nil, fmt.Errorf("retrieving Storage Account Key: %s", err) + } + + storageAuth, err := auth.NewSharedKeyAuthorizer(account.name, *accountKey, auth.SharedKey) + if err != nil { + return nil, fmt.Errorf("building Shared Key Authorizer for File Storage Shares client: %+v", err) + } + + filesClient, err := files.NewWithBaseUri(baseUri) + if err != nil { + return nil, fmt.Errorf("building File Storage Share Files client: %+v", err) + } + + filesClient.Client.SetAuthorizer(storageAuth) + + return filesClient, nil +} + +func (client Client) FileSharesDataPlaneClient(ctx context.Context, account accountDetails) (shim.StorageShareWrapper, error) { + if account.Properties == nil { + return nil, fmt.Errorf("storage account %q has no properties", account.name) + } + if account.Properties.PrimaryEndpoints == nil { + return nil, fmt.Errorf("storage account %q has missing endpoints", account.name) + } + if account.Properties.PrimaryEndpoints.File == nil { + return nil, fmt.Errorf("determing File endpoint for storage account %q", account.name) + } + + baseUri := strings.TrimSuffix(*account.Properties.PrimaryEndpoints.File, "/") + + if client.authorizerForAad != nil { + sharesClient, err := shares.NewWithBaseUri(baseUri) + if err != nil { + return nil, fmt.Errorf("building File Storage Share Shares client: %+v", err) + } + + sharesClient.Client.SetAuthorizer(client.authorizerForAad) + + return shim.NewDataPlaneStorageShareWrapper(sharesClient), nil + } + + accountKey, err := account.AccountKey(ctx, client) + if err != nil { + return nil, fmt.Errorf("retrieving Storage Account Key: %s", err) + } + + storageAuth, err := auth.NewSharedKeyAuthorizer(account.name, *accountKey, auth.SharedKey) + if err != nil { + return nil, fmt.Errorf("building Shared Key Authorizer for File Storage Shares client: %+v", err) + } + + sharesClient, err := shares.NewWithBaseUri(baseUri) + if err != nil { + return nil, fmt.Errorf("building File Storage Share Shares client: %+v", err) + } + + sharesClient.Client.SetAuthorizer(storageAuth) + + return shim.NewDataPlaneStorageShareWrapper(sharesClient), nil +} + +func (client Client) QueuesDataPlaneClient(ctx context.Context, account accountDetails) (shim.StorageQueuesWrapper, error) { + if account.Properties == nil { + return nil, fmt.Errorf("storage account %q has no properties", account.name) + } + if account.Properties.PrimaryEndpoints == nil { + return nil, fmt.Errorf("storage account %q has missing endpoints", account.name) + } + if account.Properties.PrimaryEndpoints.Queue == nil { + return nil, fmt.Errorf("determing Queue endpoint for storage account %q", account.name) + } + + baseUri := strings.TrimSuffix(*account.Properties.PrimaryEndpoints.Queue, "/") + + if client.authorizerForAad != nil { + queuesClient, err := queues.NewWithBaseUri(baseUri) + if err != nil { + return nil, fmt.Errorf("building File Storage Queue Queues client: %+v", err) + } + + queuesClient.Client.SetAuthorizer(client.authorizerForAad) + + return shim.NewDataPlaneStorageQueueWrapper(queuesClient), nil + } + + accountKey, err := account.AccountKey(ctx, client) + if err != nil { + return nil, fmt.Errorf("retrieving Storage Account Key: %s", err) + } + + storageAuth, err := auth.NewSharedKeyAuthorizer(account.name, *accountKey, auth.SharedKey) + if err != nil { + return nil, fmt.Errorf("building Queued Key Authorizer for File Storage Queues client: %+v", err) + } + + queuesClient, err := queues.NewWithBaseUri(baseUri) + if err != nil { + return nil, fmt.Errorf("building File Storage Queue Queues client: %+v", err) + } + + queuesClient.Client.SetAuthorizer(storageAuth) + + return shim.NewDataPlaneStorageQueueWrapper(queuesClient), nil +} + +func (client Client) TableEntityDataPlaneClient(ctx context.Context, account accountDetails) (*entities.Client, error) { + if account.Properties == nil { + return nil, fmt.Errorf("storage account %q has no properties", account.name) + } + if account.Properties.PrimaryEndpoints == nil { + return nil, fmt.Errorf("storage account %q has missing endpoints", account.name) + } + if account.Properties.PrimaryEndpoints.Table == nil { + return nil, fmt.Errorf("determing Table endpoint for storage account %q", account.name) + } + + baseUri := strings.TrimSuffix(*account.Properties.PrimaryEndpoints.Table, "/") + + if client.authorizerForAad != nil { + entitiesClient, err := entities.NewWithBaseUri(baseUri) + if err != nil { + return nil, fmt.Errorf("building Table Storage Share Entities client: %+v", err) + } + + entitiesClient.Client.SetAuthorizer(client.authorizerForAad) + + return entitiesClient, nil + } + + accountKey, err := account.AccountKey(ctx, client) + if err != nil { + return nil, fmt.Errorf("retrieving Storage Account Key: %s", err) + } + + storageAuth, err := auth.NewSharedKeyAuthorizer(account.name, *accountKey, auth.SharedKey) + if err != nil { + return nil, fmt.Errorf("building Shared Key Authorizer for Table Storage Shares client: %+v", err) + } + + entitiesClient, err := entities.NewWithBaseUri(baseUri) + if err != nil { + return nil, fmt.Errorf("building Table Storage Share Entities client: %+v", err) + } + + entitiesClient.Client.SetAuthorizer(storageAuth) + + return entitiesClient, nil +} + +func (client Client) TablesDataPlaneClient(ctx context.Context, account accountDetails) (shim.StorageTableWrapper, error) { + if account.Properties == nil { + return nil, fmt.Errorf("storage account %q has no properties", account.name) + } + if account.Properties.PrimaryEndpoints == nil { + return nil, fmt.Errorf("storage account %q has missing endpoints", account.name) + } + if account.Properties.PrimaryEndpoints.Table == nil { + return nil, fmt.Errorf("determing Table endpoint for storage account %q", account.name) + } + + baseUri := strings.TrimSuffix(*account.Properties.PrimaryEndpoints.Table, "/") + + if client.authorizerForAad != nil { + tablesClient, err := tables.NewWithBaseUri(baseUri) + if err != nil { + return nil, fmt.Errorf("building Table Storage Share Tables client: %+v", err) + } + + tablesClient.Client.SetAuthorizer(client.authorizerForAad) + + return shim.NewDataPlaneStorageTableWrapper(tablesClient), nil + } + + accountKey, err := account.AccountKey(ctx, client) + if err != nil { + return nil, fmt.Errorf("retrieving Storage Account Key: %s", err) + } + + storageAuth, err := auth.NewSharedKeyAuthorizer(account.name, *accountKey, auth.SharedKey) + if err != nil { + return nil, fmt.Errorf("building Shared Key Authorizer for Table Storage Shares client: %+v", err) + } + + tablesClient, err := tables.NewWithBaseUri(baseUri) + if err != nil { + return nil, fmt.Errorf("building Table Storage Share Tables client: %+v", err) + } + + tablesClient.Client.SetAuthorizer(storageAuth) + + return shim.NewDataPlaneStorageTableWrapper(tablesClient), nil +} diff --git a/internal/services/storage/helpers/schema.go b/internal/services/storage/helpers/schema.go new file mode 100644 index 000000000000..8d6cf8725a62 --- /dev/null +++ b/internal/services/storage/helpers/schema.go @@ -0,0 +1,27 @@ +package helpers + +import ( + "context" + "log" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" +) + +type StorageIDValidationFunc func(id, storageDomainSuffix string) error + +func ImporterValidatingStorageResourceId(validateFunc StorageIDValidationFunc) *schema.ResourceImporter { + return &schema.ResourceImporter{ + StateContext: func(ctx context.Context, d *pluginsdk.ResourceData, meta interface{}) ([]*pluginsdk.ResourceData, error) { + storageDomainSuffix := meta.(*clients.Client).Storage.StorageDomainSuffix + log.Printf("[DEBUG] Importing Storage Resource - parsing %q using domain suffix %q", d.Id(), storageDomainSuffix) + if _, ok := ctx.Deadline(); !ok { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, d.Timeout(schema.TimeoutRead)) + defer cancel() + } + return []*pluginsdk.ResourceData{d}, validateFunc(d.Id(), storageDomainSuffix) + }, + } +} diff --git a/internal/services/storage/migration/share.go b/internal/services/storage/migration/share.go index 348aa2fd7247..75abecf1a189 100644 --- a/internal/services/storage/migration/share.go +++ b/internal/services/storage/migration/share.go @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" + "github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts" "github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares" ) @@ -54,16 +55,18 @@ func (s ShareV1ToV2) UpgradeFunc() pluginsdk.StateUpgraderFunc { // name/resourceGroup/accountName parsedId := strings.Split(id, "/") if len(parsedId) != 3 { - return rawState, fmt.Errorf("Expected 3 segments in the ID but got %d", len(parsedId)) + return rawState, fmt.Errorf("expected 3 segments in the ID but got %d", len(parsedId)) } shareName := parsedId[0] accountName := parsedId[2] - environment := meta.(*clients.Client).Account.AzureEnvironment - client := shares.NewWithEnvironment(environment) + accountId, err := accounts.ParseAccountID(accountName, meta.(*clients.Client).Storage.StorageDomainSuffix) + if err != nil { + return rawState, fmt.Errorf("parsing Account ID: %v", err) + } - newResourceId := client.GetResourceID(accountName, shareName) + newResourceId := shares.NewShareID(*accountId, shareName) log.Printf("[DEBUG] Updating Resource ID from %q to %q", id, newResourceId) rawState["id"] = newResourceId @@ -72,7 +75,7 @@ func (s ShareV1ToV2) UpgradeFunc() pluginsdk.StateUpgraderFunc { } } -// the schema schema was used for both V0 and V1 +// this schema was used for both V0 and V1 func shareSchemaForV0AndV1() map[string]*pluginsdk.Schema { return map[string]*pluginsdk.Schema{ "name": { diff --git a/internal/services/storage/shim/containers_data_plane.go b/internal/services/storage/shim/containers_data_plane.go index c1c24e83f071..09776940a3f2 100644 --- a/internal/services/storage/shim/containers_data_plane.go +++ b/internal/services/storage/shim/containers_data_plane.go @@ -6,10 +6,11 @@ package shim import ( "context" "fmt" - "net/http" "strings" "time" + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers" ) @@ -32,7 +33,7 @@ func (w DataPlaneStorageContainerWrapper) Create(ctx context.Context, containerN if resp, err := w.client.Create(ctx, containerName, input); err != nil { // If we fail due to previous delete still in progress, then we can retry - if resp.HttpResponse.StatusCode == http.StatusConflict && strings.Contains(err.Error(), "ContainerBeingDeleted") { + if response.WasConflict(resp.HttpResponse) && strings.Contains(err.Error(), "ContainerBeingDeleted") { stateConf := &pluginsdk.StateChangeConf{ Pending: []string{"waitingOnDelete"}, Target: []string{"succeeded"}, @@ -54,7 +55,7 @@ func (w DataPlaneStorageContainerWrapper) Create(ctx context.Context, containerN func (w DataPlaneStorageContainerWrapper) Delete(ctx context.Context, containerName string) error { resp, err := w.client.Delete(ctx, containerName) - if resp.HttpResponse.StatusCode == http.StatusNotFound { + if response.WasNotFound(resp.HttpResponse) { return nil } @@ -64,19 +65,18 @@ func (w DataPlaneStorageContainerWrapper) Delete(ctx context.Context, containerN func (w DataPlaneStorageContainerWrapper) Exists(ctx context.Context, containerName string) (*bool, error) { existing, err := w.client.GetProperties(ctx, containerName, containers.GetPropertiesInput{}) if err != nil { - if existing.HttpResponse.StatusCode == http.StatusNotFound { - return nil, err + if response.WasNotFound(existing.HttpResponse) { + return pointer.To(false), nil } + return nil, err } - - exists := existing.HttpResponse.StatusCode != http.StatusNotFound - return &exists, nil + return pointer.To(true), nil } func (w DataPlaneStorageContainerWrapper) Get(ctx context.Context, containerName string) (*StorageContainerProperties, error) { props, err := w.client.GetProperties(ctx, containerName, containers.GetPropertiesInput{}) if err != nil { - if props.HttpResponse.StatusCode == http.StatusNotFound { + if response.WasNotFound(props.HttpResponse) { return nil, nil } @@ -84,10 +84,10 @@ func (w DataPlaneStorageContainerWrapper) Get(ctx context.Context, containerName } return &StorageContainerProperties{ - AccessLevel: props.Model.AccessLevel, - MetaData: props.Model.MetaData, - HasImmutabilityPolicy: props.Model.HasImmutabilityPolicy, - HasLegalHold: props.Model.HasLegalHold, + AccessLevel: props.AccessLevel, + MetaData: props.MetaData, + HasImmutabilityPolicy: props.HasImmutabilityPolicy, + HasLegalHold: props.HasLegalHold, }, nil } @@ -111,11 +111,11 @@ func (w DataPlaneStorageContainerWrapper) createRefreshFunc(ctx context.Context, return func() (interface{}, string, error) { resp, err := w.client.Create(ctx, containerName, input) if err != nil { - if resp.HttpResponse.StatusCode != http.StatusConflict { + if !response.WasConflict(resp.HttpResponse) { return nil, "", err } - if resp.HttpResponse.StatusCode == http.StatusConflict && strings.Contains(err.Error(), "ContainerBeingDeleted") { + if response.WasConflict(resp.HttpResponse) && strings.Contains(err.Error(), "ContainerBeingDeleted") { return nil, "waitingOnDelete", nil } } diff --git a/internal/services/storage/shim/queues_data_plane.go b/internal/services/storage/shim/queues_data_plane.go index 1d2aca53dd06..8b52b1e9d068 100644 --- a/internal/services/storage/shim/queues_data_plane.go +++ b/internal/services/storage/shim/queues_data_plane.go @@ -5,9 +5,9 @@ package shim import ( "context" - "net/http" - "github.com/hashicorp/terraform-provider-azurerm/utils" + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues" ) @@ -37,19 +37,18 @@ func (w DataPlaneStorageQueueWrapper) Delete(ctx context.Context, queueName stri func (w DataPlaneStorageQueueWrapper) Exists(ctx context.Context, queueName string) (*bool, error) { existing, err := w.client.GetMetaData(ctx, queueName) if err != nil { - if existing.HttpResponse.StatusCode == http.StatusNotFound { - return utils.Bool(false), nil + if response.WasNotFound(existing.HttpResponse) { + return pointer.To(false), nil } return nil, err } - - return utils.Bool(true), nil + return pointer.To(true), nil } func (w DataPlaneStorageQueueWrapper) Get(ctx context.Context, queueName string) (*StorageQueueProperties, error) { props, err := w.client.GetMetaData(ctx, queueName) if err != nil { - if props.HttpResponse.StatusCode == http.StatusNotFound { + if response.WasNotFound(props.HttpResponse) { return nil, nil } return nil, err @@ -63,7 +62,7 @@ func (w DataPlaneStorageQueueWrapper) Get(ctx context.Context, queueName string) func (w DataPlaneStorageQueueWrapper) GetServiceProperties(ctx context.Context) (*queues.StorageServiceProperties, error) { serviceProps, err := w.client.GetServiceProperties(ctx) if err != nil { - if serviceProps.HttpResponse.StatusCode == http.StatusNotFound { + if response.WasNotFound(serviceProps.HttpResponse) { return nil, nil } return nil, err diff --git a/internal/services/storage/shim/shares_data_plane.go b/internal/services/storage/shim/shares_data_plane.go index 16005d9b9993..ba0863d75199 100644 --- a/internal/services/storage/shim/shares_data_plane.go +++ b/internal/services/storage/shim/shares_data_plane.go @@ -6,12 +6,12 @@ package shim import ( "context" "fmt" - "net/http" "strings" "time" + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" - "github.com/hashicorp/terraform-provider-azurerm/utils" "github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares" ) @@ -37,7 +37,7 @@ func (w DataPlaneStorageShareWrapper) Create(ctx context.Context, shareName stri } // If we fail due to previous delete still in progress, then we can retry - if resp.HttpResponse.StatusCode == http.StatusConflict && strings.Contains(err.Error(), "ShareBeingDeleted") { + if response.WasConflict(resp.HttpResponse) && strings.Contains(err.Error(), "ShareBeingDeleted") { stateConf := &pluginsdk.StateChangeConf{ Pending: []string{"waitingOnDelete"}, Target: []string{"succeeded"}, @@ -66,20 +66,18 @@ func (w DataPlaneStorageShareWrapper) Delete(ctx context.Context, shareName stri func (w DataPlaneStorageShareWrapper) Exists(ctx context.Context, shareName string) (*bool, error) { existing, err := w.client.GetProperties(ctx, shareName) if err != nil { - if existing.HttpResponse.StatusCode == http.StatusNotFound { - return nil, nil + if response.WasNotFound(existing.HttpResponse) { + return pointer.To(false), nil } - return nil, err } - - return utils.Bool(true), nil + return pointer.To(true), nil } func (w DataPlaneStorageShareWrapper) Get(ctx context.Context, shareName string) (*StorageShareProperties, error) { props, err := w.client.GetProperties(ctx, shareName) if err != nil { - if props.HttpResponse.StatusCode == http.StatusNotFound { + if response.WasNotFound(props.HttpResponse) { return nil, nil } @@ -132,11 +130,11 @@ func (w DataPlaneStorageShareWrapper) createRefreshFunc(ctx context.Context, sha return func() (interface{}, string, error) { resp, err := w.client.Create(ctx, shareName, input) if err != nil { - if resp.HttpResponse.StatusCode != http.StatusConflict { + if !response.WasConflict(resp.HttpResponse) { return nil, "", err } - if resp.HttpResponse.StatusCode == http.StatusConflict && strings.Contains(err.Error(), "ShareBeingDeleted") { + if response.WasConflict(resp.HttpResponse) && strings.Contains(err.Error(), "ShareBeingDeleted") { return nil, "waitingOnDelete", nil } } diff --git a/internal/services/storage/shim/tables_data_plane.go b/internal/services/storage/shim/tables_data_plane.go index 6f63cccfafe1..447fca894677 100644 --- a/internal/services/storage/shim/tables_data_plane.go +++ b/internal/services/storage/shim/tables_data_plane.go @@ -5,9 +5,9 @@ package shim import ( "context" - "net/http" - "github.com/hashicorp/terraform-provider-azurerm/utils" + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables" ) @@ -34,14 +34,12 @@ func (w DataPlaneStorageTableWrapper) Delete(ctx context.Context, tableName stri func (w DataPlaneStorageTableWrapper) Exists(ctx context.Context, tableName string) (*bool, error) { existing, err := w.client.Exists(ctx, tableName) if err != nil { - if existing.HttpResponse.StatusCode != http.StatusNotFound { - return nil, nil + if response.WasNotFound(existing.HttpResponse) { + return pointer.To(false), nil } - return nil, err } - - return utils.Bool(true), nil + return pointer.To(true), nil } func (w DataPlaneStorageTableWrapper) GetACLs(ctx context.Context, tableName string) (*[]tables.SignedIdentifier, error) { diff --git a/internal/services/storage/storage_account_resource.go b/internal/services/storage/storage_account_resource.go index 167822bb9ce1..5912a9e8c48d 100644 --- a/internal/services/storage/storage_account_resource.go +++ b/internal/services/storage/storage_account_resource.go @@ -1303,7 +1303,7 @@ func resourceStorageAccountCreate(d *pluginsdk.ResourceData, meta interface{}) e existing, err := client.GetProperties(ctx, id.ResourceGroupName, id.StorageAccountName, "") if err != nil { if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("checking for presence of existing %s: %s", id, err) + return fmt.Errorf("checking for existing %s: %s", id, err) } } @@ -1575,7 +1575,7 @@ func resourceStorageAccountCreate(d *pluginsdk.ResourceData, meta interface{}) e return fmt.Errorf("unable to locate %q", id) } - queueClient, err := storageClient.QueuesClient(ctx, *account) + queueClient, err := storageClient.QueuesDataPlaneClient(ctx, *account) if err != nil { return fmt.Errorf("building Queues Client: %s", err) } @@ -2044,7 +2044,7 @@ func resourceStorageAccountUpdate(d *pluginsdk.ResourceData, meta interface{}) e return fmt.Errorf("unable to locate %s", *id) } - queueClient, err := storageClient.QueuesClient(ctx, *account) + queueClient, err := storageClient.QueuesDataPlaneClient(ctx, *account) if err != nil { return fmt.Errorf("building Queues Client: %s", err) } @@ -2378,7 +2378,7 @@ func resourceStorageAccountRead(d *pluginsdk.ResourceData, meta interface{}) err } if supportLevel.supportQueue { - queueClient, err := storageClient.QueuesClient(ctx, *account) + queueClient, err := storageClient.QueuesDataPlaneClient(ctx, *account) if err != nil { return fmt.Errorf("building Queues Client: %s", err) } @@ -3708,18 +3708,16 @@ func flattenedSharePropertiesSMB(input *storage.SmbSetting) []interface{} { } func flattenStaticWebsiteProperties(input accounts.GetServicePropertiesResult) []interface{} { - if storageServiceProps := input.Model; storageServiceProps != nil { - if staticWebsite := storageServiceProps.StaticWebsite; staticWebsite != nil { - if !staticWebsite.Enabled { - return []interface{}{} - } + if staticWebsite := input.StaticWebsite; staticWebsite != nil { + if !staticWebsite.Enabled { + return []interface{}{} + } - return []interface{}{ - map[string]interface{}{ - "index_document": staticWebsite.IndexDocument, - "error_404_document": staticWebsite.ErrorDocument404Path, - }, - } + return []interface{}{ + map[string]interface{}{ + "index_document": staticWebsite.IndexDocument, + "error_404_document": staticWebsite.ErrorDocument404Path, + }, } } return []interface{}{} diff --git a/internal/services/storage/storage_blob_data_source.go b/internal/services/storage/storage_blob_data_source.go index b7cbc4430557..305d72cb8e62 100644 --- a/internal/services/storage/storage_blob_data_source.go +++ b/internal/services/storage/storage_blob_data_source.go @@ -5,8 +5,8 @@ package storage import ( "fmt" + "github.com/hashicorp/go-azure-helpers/lang/response" "log" - "net/http" "strings" "time" @@ -89,7 +89,7 @@ func dataSourceStorageBlobRead(d *pluginsdk.ResourceData, meta interface{}) erro return fmt.Errorf("locating Storage Account %q", accountName) } - blobsClient, err := storageClient.BlobsClient(ctx, *account) + blobsClient, err := storageClient.BlobsDataPlaneClient(ctx, *account) if err != nil { return fmt.Errorf("building Blobs Client: %v", err) } @@ -105,7 +105,7 @@ func dataSourceStorageBlobRead(d *pluginsdk.ResourceData, meta interface{}) erro input := blobs.GetPropertiesInput{} props, err := blobsClient.GetProperties(ctx, containerName, name, input) if err != nil { - if props.HttpResponse.StatusCode == http.StatusNotFound { + if response.WasNotFound(props.HttpResponse) { return fmt.Errorf("%s was not found", id) } diff --git a/internal/services/storage/storage_blob_resource.go b/internal/services/storage/storage_blob_resource.go index 821ee95683ee..2a879d767b65 100644 --- a/internal/services/storage/storage_blob_resource.go +++ b/internal/services/storage/storage_blob_resource.go @@ -7,12 +7,13 @@ import ( "context" "fmt" "log" - "net/http" "strings" "time" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/helpers" "github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/migration" "github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" @@ -35,8 +36,8 @@ func resourceStorageBlob() *pluginsdk.Resource { 0: migration.BlobV0ToV1{}, }), - Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := blobs.ParseBlobID(id, "") // TODO: actual domain suffix needed here! + Importer: helpers.ImporterValidatingStorageResourceId(func(id, storageDomainSuffix string) error { + _, err := blobs.ParseBlobID(id, storageDomainSuffix) return err }), @@ -183,7 +184,7 @@ func resourceStorageBlobCreate(d *pluginsdk.ResourceData, meta interface{}) erro return fmt.Errorf("locating Storage Account %q", accountName) } - blobsClient, err := storageClient.BlobsClient(ctx, *account) + blobsClient, err := storageClient.BlobsDataPlaneClient(ctx, *account) if err != nil { return fmt.Errorf("building Blobs Client: %v", err) } @@ -198,11 +199,11 @@ func resourceStorageBlobCreate(d *pluginsdk.ResourceData, meta interface{}) erro input := blobs.GetPropertiesInput{} props, err := blobsClient.GetProperties(ctx, containerName, name, input) if err != nil { - if props.HttpResponse.StatusCode != http.StatusNotFound { + if !response.WasNotFound(props.HttpResponse) { return fmt.Errorf("checking for existing %s: %v", id, err) } } - if props.HttpResponse.StatusCode != http.StatusNotFound { + if !response.WasNotFound(props.HttpResponse) { return tf.ImportAsExistsError("azurerm_storage_blob", id.ID()) } } @@ -264,7 +265,7 @@ func resourceStorageBlobUpdate(d *pluginsdk.ResourceData, meta interface{}) erro return fmt.Errorf("locating Storage Account %q", id.AccountId.AccountName) } - blobsClient, err := storageClient.BlobsClient(ctx, *account) + blobsClient, err := storageClient.BlobsDataPlaneClient(ctx, *account) if err != nil { return fmt.Errorf("building Blobs Client: %v", err) } @@ -339,7 +340,7 @@ func resourceStorageBlobRead(d *pluginsdk.ResourceData, meta interface{}) error return nil } - blobsClient, err := storageClient.BlobsClient(ctx, *account) + blobsClient, err := storageClient.BlobsDataPlaneClient(ctx, *account) if err != nil { return fmt.Errorf("building Blobs Client: %v", err) } @@ -348,7 +349,7 @@ func resourceStorageBlobRead(d *pluginsdk.ResourceData, meta interface{}) error input := blobs.GetPropertiesInput{} props, err := blobsClient.GetProperties(ctx, id.ContainerName, id.BlobName, input) if err != nil { - if props.HttpResponse.StatusCode == http.StatusNotFound { + if response.WasNotFound(props.HttpResponse) { log.Printf("[INFO] Blob %q was not found in Container %q / Account %q - assuming removed & removing from state...", id.BlobName, id.ContainerName, id.AccountId.AccountName) d.SetId("") return nil @@ -408,7 +409,7 @@ func resourceStorageBlobDelete(d *pluginsdk.ResourceData, meta interface{}) erro return fmt.Errorf("locating Storage Account %q", id.AccountId.AccountName) } - blobsClient, err := storageClient.BlobsClient(ctx, *account) + blobsClient, err := storageClient.BlobsDataPlaneClient(ctx, *account) if err != nil { return fmt.Errorf("building Blobs Client: %v", err) } diff --git a/internal/services/storage/storage_blob_resource_test.go b/internal/services/storage/storage_blob_resource_test.go index a6604ce689cf..cef0f91ac163 100644 --- a/internal/services/storage/storage_blob_resource_test.go +++ b/internal/services/storage/storage_blob_resource_test.go @@ -7,7 +7,7 @@ import ( "context" "crypto/rand" "fmt" - "net/http" + "github.com/hashicorp/go-azure-helpers/lang/response" "os" "regexp" "testing" @@ -481,14 +481,14 @@ func (r StorageBlobResource) Exists(ctx context.Context, client *clients.Client, if account == nil { return nil, fmt.Errorf("unable to locate Account %q for Blob %q (Container %q)", id.AccountId.AccountName, id.BlobName, id.ContainerName) } - blobsClient, err := client.Storage.BlobsClient(ctx, *account) + blobsClient, err := client.Storage.BlobsDataPlaneClient(ctx, *account) if err != nil { return nil, fmt.Errorf("building Blobs Client: %+v", err) } input := blobs.GetPropertiesInput{} resp, err := blobsClient.GetProperties(ctx, id.ContainerName, id.BlobName, input) if err != nil { - if resp.HttpResponse.StatusCode == http.StatusNotFound { + if response.WasNotFound(resp.HttpResponse) { return utils.Bool(false), nil } return nil, fmt.Errorf("retrieving Blob %q (Container %q / Account %q): %+v", id.BlobName, id.ContainerName, id.AccountId.AccountName, err) @@ -505,7 +505,7 @@ func (r StorageBlobResource) Destroy(ctx context.Context, client *clients.Client if err != nil { return nil, fmt.Errorf("retrieving Account %q for Blob %q (Container %q): %+v", id.AccountId.AccountName, id.BlobName, id.ContainerName, err) } - blobsClient, err := client.Storage.BlobsClient(ctx, *account) + blobsClient, err := client.Storage.BlobsDataPlaneClient(ctx, *account) if err != nil { return nil, fmt.Errorf("building Blobs Client: %+v", err) } @@ -532,7 +532,7 @@ func (r StorageBlobResource) blobMatchesFile(kind blobs.BlobType, filePath strin return fmt.Errorf("Unable to locate Storage Account %q!", accountName) } - client, err := clients.Storage.BlobsClient(ctx, *account) + client, err := clients.Storage.BlobsDataPlaneClient(ctx, *account) if err != nil { return fmt.Errorf("building Blobs Client: %s", err) } diff --git a/internal/services/storage/storage_container_data_source.go b/internal/services/storage/storage_container_data_source.go index 902b2433d584..141a535bd9cd 100644 --- a/internal/services/storage/storage_container_data_source.go +++ b/internal/services/storage/storage_container_data_source.go @@ -75,7 +75,7 @@ func dataSourceStorageContainerRead(d *pluginsdk.ResourceData, meta interface{}) return fmt.Errorf("locating Storage Account %q for Container %q", accountName, containerName) } - client, err := storageClient.ContainersClient(ctx, *account) + client, err := storageClient.ContainersDataPlaneClient(ctx, *account) if err != nil { return fmt.Errorf("building Containers Client: %v", err) } diff --git a/internal/services/storage/storage_container_resource.go b/internal/services/storage/storage_container_resource.go index 254149d5e486..2c96d3b4fe58 100644 --- a/internal/services/storage/storage_container_resource.go +++ b/internal/services/storage/storage_container_resource.go @@ -11,6 +11,7 @@ import ( "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/helpers" "github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/migration" "github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/validate" @@ -27,8 +28,8 @@ func resourceStorageContainer() *pluginsdk.Resource { Delete: resourceStorageContainerDelete, Update: resourceStorageContainerUpdate, - Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.StorageContainerDataPlaneID(id, "") // TODO: actual domain suffix needed here! + Importer: helpers.ImporterValidatingStorageResourceId(func(id, storageDomainSuffix string) error { + _, err := parse.StorageContainerDataPlaneID(id, storageDomainSuffix) return err }), @@ -112,7 +113,7 @@ func resourceStorageContainerCreate(d *pluginsdk.ResourceData, meta interface{}) return fmt.Errorf("locating Storage Account %q", accountName) } - client, err := storageClient.ContainersClient(ctx, *account) + client, err := storageClient.ContainersDataPlaneClient(ctx, *account) if err != nil { return fmt.Errorf("building storage client: %v", err) } @@ -121,7 +122,7 @@ func resourceStorageContainerCreate(d *pluginsdk.ResourceData, meta interface{}) exists, err := client.Exists(ctx, containerName) if err != nil { - return err + return fmt.Errorf("checking for existing %s: %v", id, err) } if exists != nil && *exists { return tf.ImportAsExistsError("azurerm_storage_container", id.ID()) @@ -160,7 +161,7 @@ func resourceStorageContainerUpdate(d *pluginsdk.ResourceData, meta interface{}) return fmt.Errorf("locating Storage Account %q", id.AccountName) } - client, err := storageClient.ContainersClient(ctx, *account) + client, err := storageClient.ContainersDataPlaneClient(ctx, *account) if err != nil { return fmt.Errorf("building Containers Client: %v", err) } @@ -213,7 +214,7 @@ func resourceStorageContainerRead(d *pluginsdk.ResourceData, meta interface{}) e return nil } - client, err := storageClient.ContainersClient(ctx, *account) + client, err := storageClient.ContainersDataPlaneClient(ctx, *account) if err != nil { return fmt.Errorf("building Containers Client: %v", err) } @@ -264,7 +265,7 @@ func resourceStorageContainerDelete(d *pluginsdk.ResourceData, meta interface{}) return fmt.Errorf("locating Storage Account %q", id.AccountName) } - client, err := storageClient.ContainersClient(ctx, *account) + client, err := storageClient.ContainersDataPlaneClient(ctx, *account) if err != nil { return fmt.Errorf("building Containers Client: %v", err) } diff --git a/internal/services/storage/storage_container_resource_test.go b/internal/services/storage/storage_container_resource_test.go index 3ab6249f10c2..dfe1ecbba2d3 100644 --- a/internal/services/storage/storage_container_resource_test.go +++ b/internal/services/storage/storage_container_resource_test.go @@ -199,7 +199,7 @@ func (r StorageContainerResource) Exists(ctx context.Context, client *clients.Cl return nil, fmt.Errorf("unable to locate Storage Account %q", id.AccountName) } - containersClient, err := client.Storage.ContainersClient(ctx, *account) + containersClient, err := client.Storage.ContainersDataPlaneClient(ctx, *account) if err != nil { return nil, fmt.Errorf("building Containers Client: %+v", err) } @@ -222,7 +222,7 @@ func (r StorageContainerResource) Destroy(ctx context.Context, client *clients.C if account == nil { return nil, fmt.Errorf("unable to locate Storage Account %q", id.AccountName) } - containersClient, err := client.Storage.ContainersClient(ctx, *account) + containersClient, err := client.Storage.ContainersDataPlaneClient(ctx, *account) if err != nil { return nil, fmt.Errorf("building Containers Client: %+v", err) } diff --git a/internal/services/storage/storage_data_lake_gen2_filesystem_resource.go b/internal/services/storage/storage_data_lake_gen2_filesystem_resource.go index ab648c583e95..ab968ed009c1 100644 --- a/internal/services/storage/storage_data_lake_gen2_filesystem_resource.go +++ b/internal/services/storage/storage_data_lake_gen2_filesystem_resource.go @@ -7,10 +7,10 @@ import ( "context" "fmt" "log" - "net/http" "regexp" "time" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" @@ -176,12 +176,12 @@ func resourceStorageDataLakeGen2FileSystemCreate(d *pluginsdk.ResourceData, meta resp, err := client.GetProperties(ctx, fileSystemName) if err != nil { - if resp.HttpResponse.StatusCode != http.StatusNotFound { + if !response.WasNotFound(resp.HttpResponse) { return fmt.Errorf("checking for existence of existing File System %q in %s: %v", fileSystemName, accountId, err) } } - if resp.HttpResponse.StatusCode != http.StatusNotFound { + if !response.WasNotFound(resp.HttpResponse) { return tf.ImportAsExistsError("azurerm_storage_data_lake_gen2_filesystem", id.ID()) } @@ -339,7 +339,7 @@ func resourceStorageDataLakeGen2FileSystemRead(d *pluginsdk.ResourceData, meta i resp, err := client.GetProperties(ctx, id.FileSystemName) if err != nil { - if resp.HttpResponse.StatusCode == http.StatusNotFound { + if response.WasNotFound(resp.HttpResponse) { log.Printf("[INFO] File System %q does not exist in Storage Account %q - removing from state...", id.FileSystemName, id.AccountId.AccountName) d.SetId("") return nil @@ -392,7 +392,7 @@ func resourceStorageDataLakeGen2FileSystemDelete(d *pluginsdk.ResourceData, meta resp, err := client.Delete(ctx, id.FileSystemName) if err != nil { - if resp.HttpResponse.StatusCode != http.StatusNotFound { + if !response.WasNotFound(resp.HttpResponse) { return fmt.Errorf("deleting %s: %v", id, err) } } diff --git a/internal/services/storage/storage_data_lake_gen2_filesystem_resource_test.go b/internal/services/storage/storage_data_lake_gen2_filesystem_resource_test.go index d6d995cb3e7b..6ed02552aa16 100644 --- a/internal/services/storage/storage_data_lake_gen2_filesystem_resource_test.go +++ b/internal/services/storage/storage_data_lake_gen2_filesystem_resource_test.go @@ -6,7 +6,7 @@ package storage_test import ( "context" "fmt" - "net/http" + "github.com/hashicorp/go-azure-helpers/lang/response" "testing" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" @@ -154,7 +154,7 @@ func (r StorageDataLakeGen2FileSystemResource) Exists(ctx context.Context, clien } resp, err := client.Storage.FileSystemsClient.GetProperties(ctx, id.FileSystemName) if err != nil { - if resp.HttpResponse.StatusCode == http.StatusNotFound { + if response.WasNotFound(resp.HttpResponse) { return utils.Bool(false), nil } return nil, fmt.Errorf("retrieving File System %q (Account %q): %+v", id.FileSystemName, id.AccountId.AccountName, err) diff --git a/internal/services/storage/storage_data_lake_gen2_path_resource.go b/internal/services/storage/storage_data_lake_gen2_path_resource.go index e21482b66a8c..ec53442498d5 100644 --- a/internal/services/storage/storage_data_lake_gen2_path_resource.go +++ b/internal/services/storage/storage_data_lake_gen2_path_resource.go @@ -7,9 +7,9 @@ import ( "context" "fmt" "log" - "net/http" "time" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" @@ -176,11 +176,11 @@ func resourceStorageDataLakeGen2PathCreate(d *pluginsdk.ResourceData, meta inter id := paths.NewPathID(*accountId, fileSystemName, path) resp, err := client.GetProperties(ctx, fileSystemName, path, paths.GetPropertiesInput{Action: paths.GetPropertiesActionGetStatus}) if err != nil { - if resp.HttpResponse.StatusCode != http.StatusNotFound { + if !response.WasNotFound(resp.HttpResponse) { return fmt.Errorf("checking for existence of existing Path %q in File System %q in %s: %v", path, fileSystemName, storageId, err) } } - if resp.HttpResponse.StatusCode != http.StatusNotFound { + if !response.WasNotFound(resp.HttpResponse) { return tf.ImportAsExistsError("azurerm_storage_data_lake_gen2_path", id.ID()) } @@ -316,7 +316,7 @@ func resourceStorageDataLakeGen2PathRead(d *pluginsdk.ResourceData, meta interfa resp, err := client.GetProperties(ctx, id.FileSystemName, id.Path, paths.GetPropertiesInput{Action: paths.GetPropertiesActionGetStatus}) if err != nil { - if resp.HttpResponse.StatusCode == http.StatusNotFound { + if response.WasNotFound(resp.HttpResponse) { log.Printf("[INFO] Path %q does not exist in File System %q in Storage Account %q - removing from state...", id.Path, id.FileSystemName, id.AccountId.AccountName) d.SetId("") return nil @@ -334,7 +334,7 @@ func resourceStorageDataLakeGen2PathRead(d *pluginsdk.ResourceData, meta interfa // Have to make a `getAccessControl` request, but that doesn't return all fields either! resp, err = client.GetProperties(ctx, id.FileSystemName, id.Path, paths.GetPropertiesInput{Action: paths.GetPropertiesActionGetAccessControl}) if err != nil { - if resp.HttpResponse.StatusCode == http.StatusNotFound { + if response.WasNotFound(resp.HttpResponse) { log.Printf("[INFO] Path %q does not exist in File System %q in Storage Account %q - removing from state...", id.Path, id.FileSystemName, id.AccountId.AccountName) d.SetId("") return nil @@ -365,7 +365,7 @@ func resourceStorageDataLakeGen2PathDelete(d *pluginsdk.ResourceData, meta inter resp, err := client.Delete(ctx, id.FileSystemName, id.Path) if err != nil { - if resp.HttpResponse.StatusCode != http.StatusNotFound { + if !response.WasNotFound(resp.HttpResponse) { return fmt.Errorf("deleting %s: %v", id, err) } } diff --git a/internal/services/storage/storage_data_lake_gen2_path_resource_test.go b/internal/services/storage/storage_data_lake_gen2_path_resource_test.go index 42a8e77d047e..bb352b912530 100644 --- a/internal/services/storage/storage_data_lake_gen2_path_resource_test.go +++ b/internal/services/storage/storage_data_lake_gen2_path_resource_test.go @@ -6,7 +6,7 @@ package storage_test import ( "context" "fmt" - "net/http" + "github.com/hashicorp/go-azure-helpers/lang/response" "testing" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" @@ -138,7 +138,7 @@ func (r StorageDataLakeGen2PathResource) Exists(ctx context.Context, client *cli } resp, err := client.Storage.ADLSGen2PathsClient.GetProperties(ctx, id.FileSystemName, id.Path, paths.GetPropertiesInput{Action: paths.GetPropertiesActionGetStatus}) if err != nil { - if resp.HttpResponse.StatusCode == http.StatusNotFound { + if response.WasNotFound(resp.HttpResponse) { return utils.Bool(false), nil } return nil, fmt.Errorf("retrieving Path %q (File System %q / Account %q): %+v", id.Path, id.FileSystemName, id.AccountId.AccountName, err) diff --git a/internal/services/storage/storage_queue_resource.go b/internal/services/storage/storage_queue_resource.go index 4fa813aa7cea..b358e4661d36 100644 --- a/internal/services/storage/storage_queue_resource.go +++ b/internal/services/storage/storage_queue_resource.go @@ -10,6 +10,7 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/helpers" "github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/migration" "github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/validate" @@ -24,8 +25,8 @@ func resourceStorageQueue() *pluginsdk.Resource { Update: resourceStorageQueueUpdate, Delete: resourceStorageQueueDelete, - Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.StorageQueueDataPlaneID(id, "") // TODO: actual domain suffix needed here! + Importer: helpers.ImporterValidatingStorageResourceId(func(id, storageDomainSuffix string) error { + _, err := parse.StorageQueueDataPlaneID(id, storageDomainSuffix) return err }), @@ -85,7 +86,7 @@ func resourceStorageQueueCreate(d *pluginsdk.ResourceData, meta interface{}) err return fmt.Errorf("locating Storage Account %q", accountName) } - client, err := storageClient.QueuesClient(ctx, *account) + client, err := storageClient.QueuesDataPlaneClient(ctx, *account) if err != nil { return fmt.Errorf("building Queues Client: %v", err) } @@ -94,7 +95,7 @@ func resourceStorageQueueCreate(d *pluginsdk.ResourceData, meta interface{}) err exists, err := client.Exists(ctx, queueName) if err != nil { - return fmt.Errorf("checking for presence of existing %s: %v", id, err) + return fmt.Errorf("checking for existing %s: %v", id, err) } if exists != nil && *exists { return tf.ImportAsExistsError("azurerm_storage_queue", id) @@ -130,7 +131,7 @@ func resourceStorageQueueUpdate(d *pluginsdk.ResourceData, meta interface{}) err return fmt.Errorf("locating Storage Account %q", id.AccountName) } - client, err := storageClient.QueuesClient(ctx, *account) + client, err := storageClient.QueuesDataPlaneClient(ctx, *account) if err != nil { return fmt.Errorf("building Queues Client: %v", err) } @@ -163,7 +164,7 @@ func resourceStorageQueueRead(d *pluginsdk.ResourceData, meta interface{}) error return nil } - client, err := storageClient.QueuesClient(ctx, *account) + client, err := storageClient.QueuesDataPlaneClient(ctx, *account) if err != nil { return fmt.Errorf("building Queues Client: %v", err) } @@ -211,7 +212,7 @@ func resourceStorageQueueDelete(d *pluginsdk.ResourceData, meta interface{}) err return nil } - client, err := storageClient.QueuesClient(ctx, *account) + client, err := storageClient.QueuesDataPlaneClient(ctx, *account) if err != nil { return fmt.Errorf("building Queues Client: %v", err) } diff --git a/internal/services/storage/storage_queue_resource_test.go b/internal/services/storage/storage_queue_resource_test.go index 39375ef5fcda..e167203f1c23 100644 --- a/internal/services/storage/storage_queue_resource_test.go +++ b/internal/services/storage/storage_queue_resource_test.go @@ -97,7 +97,7 @@ func (r StorageQueueResource) Exists(ctx context.Context, client *clients.Client if account == nil { return nil, fmt.Errorf("unable to determine Resource Group for Storage Queue %q (Account %q)", id.Name, id.AccountName) } - queuesClient, err := client.Storage.QueuesClient(ctx, *account) + queuesClient, err := client.Storage.QueuesDataPlaneClient(ctx, *account) if err != nil { return nil, fmt.Errorf("building Queues Client: %+v", err) } diff --git a/internal/services/storage/storage_share_data_source.go b/internal/services/storage/storage_share_data_source.go index c978f9c18f18..7f420f4b29c6 100644 --- a/internal/services/storage/storage_share_data_source.go +++ b/internal/services/storage/storage_share_data_source.go @@ -96,7 +96,7 @@ func dataSourceStorageShareRead(d *pluginsdk.ResourceData, meta interface{}) err return fmt.Errorf("locating Storage Account %q for Share %q", accountName, shareName) } - client, err := storageClient.FileSharesClient(ctx, *account) + client, err := storageClient.FileSharesDataPlaneClient(ctx, *account) if err != nil { return fmt.Errorf("building FileShares Client: %v", err) } diff --git a/internal/services/storage/storage_share_directory_resource.go b/internal/services/storage/storage_share_directory_resource.go index 856a9540b423..c23cf97c3c21 100644 --- a/internal/services/storage/storage_share_directory_resource.go +++ b/internal/services/storage/storage_share_directory_resource.go @@ -7,12 +7,13 @@ import ( "context" "fmt" "log" - "net/http" "strconv" "time" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/helpers" "github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" @@ -28,8 +29,8 @@ func resourceStorageShareDirectory() *pluginsdk.Resource { Update: resourceStorageShareDirectoryUpdate, Delete: resourceStorageShareDirectoryDelete, - Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := directories.ParseDirectoryID(id, "") // TODO: actual domain suffix needed here! + Importer: helpers.ImporterValidatingStorageResourceId(func(id, storageDomainSuffix string) error { + _, err := directories.ParseDirectoryID(id, storageDomainSuffix) return err }), @@ -92,19 +93,19 @@ func resourceStorageShareDirectoryCreate(d *pluginsdk.ResourceData, meta interfa id := directories.NewDirectoryID(*accountId, shareName, directoryName) - client, err := storageClient.FileShareDirectoriesClient(ctx, *account) + client, err := storageClient.FileShareDirectoriesDataPlaneClient(ctx, *account) if err != nil { return fmt.Errorf("building File Share Directories Client: %v", err) } existing, err := client.Get(ctx, shareName, directoryName) if err != nil { - if existing.HttpResponse.StatusCode != http.StatusNotFound { - return fmt.Errorf("checking for presence of existing %s: %s", id, err) + if !response.WasNotFound(existing.HttpResponse) { + return fmt.Errorf("checking for existing %s: %s", id, err) } } - if existing.HttpResponse.StatusCode != http.StatusNotFound { + if !response.WasNotFound(existing.HttpResponse) { return tf.ImportAsExistsError("azurerm_storage_share_directory", id.ID()) } @@ -156,7 +157,7 @@ func resourceStorageShareDirectoryUpdate(d *pluginsdk.ResourceData, meta interfa return fmt.Errorf("Unable to locate Storage Account %q!", id.AccountId.AccountName) } - client, err := storageClient.FileShareDirectoriesClient(ctx, *account) + client, err := storageClient.FileShareDirectoriesDataPlaneClient(ctx, *account) if err != nil { return fmt.Errorf("building File Share Client: %v", err) } @@ -188,7 +189,7 @@ func resourceStorageShareDirectoryRead(d *pluginsdk.ResourceData, meta interface return nil } - client, err := storageClient.FileShareDirectoriesClient(ctx, *account) + client, err := storageClient.FileShareDirectoriesDataPlaneClient(ctx, *account) if err != nil { return fmt.Errorf("building File Share Client: %v", err) } @@ -227,7 +228,7 @@ func resourceStorageShareDirectoryDelete(d *pluginsdk.ResourceData, meta interfa return fmt.Errorf("locating Storage Account %q", id.AccountId.AccountName) } - client, err := storageClient.FileShareDirectoriesClient(ctx, *account) + client, err := storageClient.FileShareDirectoriesDataPlaneClient(ctx, *account) if err != nil { return fmt.Errorf("building File Share Client: %v", err) } diff --git a/internal/services/storage/storage_share_directory_resource_test.go b/internal/services/storage/storage_share_directory_resource_test.go index fe46fe949679..98a477d52457 100644 --- a/internal/services/storage/storage_share_directory_resource_test.go +++ b/internal/services/storage/storage_share_directory_resource_test.go @@ -6,7 +6,7 @@ package storage_test import ( "context" "fmt" - "net/http" + "github.com/hashicorp/go-azure-helpers/lang/response" "testing" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" @@ -131,13 +131,13 @@ func (r StorageShareDirectoryResource) Exists(ctx context.Context, client *clien if account == nil { return nil, fmt.Errorf("unable to determine Resource Group for Storage Share Directory %q (Share %q / Account %q)", id.DirectoryPath, id.ShareName, id.AccountId.AccountName) } - dirClient, err := client.Storage.FileShareDirectoriesClient(ctx, *account) + dirClient, err := client.Storage.FileShareDirectoriesDataPlaneClient(ctx, *account) if err != nil { return nil, fmt.Errorf("building File Share client for Storage Account %q (Resource Group %q): %+v", id.AccountId.AccountName, account.ResourceGroup, err) } resp, err := dirClient.Get(ctx, id.ShareName, id.DirectoryPath) if err != nil { - if resp.HttpResponse.StatusCode == http.StatusNotFound { + if response.WasNotFound(resp.HttpResponse) { return utils.Bool(false), nil } return nil, fmt.Errorf("retrieving Storage Share %q (File Share %q / Account %q / Resource Group %q): %s", id.DirectoryPath, id.ShareName, id.AccountId.AccountName, account.ResourceGroup, err) diff --git a/internal/services/storage/storage_share_file_resource.go b/internal/services/storage/storage_share_file_resource.go index c125001bc30a..94c234eb58d2 100644 --- a/internal/services/storage/storage_share_file_resource.go +++ b/internal/services/storage/storage_share_file_resource.go @@ -6,12 +6,13 @@ package storage import ( "fmt" "log" - "net/http" "os" "time" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/helpers" "github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/parse" storageValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" @@ -29,8 +30,8 @@ func resourceStorageShareFile() *pluginsdk.Resource { Update: resourceStorageShareFileUpdate, Delete: resourceStorageShareFileDelete, - Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := files.ParseFileID(id, "") // TODO: actual domain suffix needed here! + Importer: helpers.ImporterValidatingStorageResourceId(func(id, storageDomainSuffix string) error { + _, err := files.ParseFileID(id, storageDomainSuffix) return err }), @@ -51,7 +52,7 @@ func resourceStorageShareFile() *pluginsdk.Resource { Type: pluginsdk.TypeString, Required: true, ForceNew: true, - ValidateFunc: storageValidate.StorageShareID, + ValidateFunc: storageValidate.StorageShareIDForDomainSuffix(""), // TODO need to know the storage domain suffix at schema time! }, "path": { Type: pluginsdk.TypeString, @@ -131,7 +132,7 @@ func resourceStorageShareFileCreate(d *pluginsdk.ResourceData, meta interface{}) id := files.NewFileID(*accountId, storageShareId.Name, path, fileName) - fileSharesClient, err := storageClient.FileSharesClient(ctx, *account) + fileSharesClient, err := storageClient.FileSharesDataPlaneClient(ctx, *account) if err != nil { return fmt.Errorf("building File Share Directories Client: %v", err) } @@ -144,19 +145,19 @@ func resourceStorageShareFileCreate(d *pluginsdk.ResourceData, meta interface{}) return fmt.Errorf("unable to locate Storage Share %q", storageShareId.Name) } - client, err := storageClient.FileShareFilesClient(ctx, *account) + client, err := storageClient.FileShareFilesDataPlaneClient(ctx, *account) if err != nil { return fmt.Errorf("building File Share Directories Client: %s", err) } existing, err := client.GetProperties(ctx, storageShareId.Name, path, fileName) if err != nil { - if existing.HttpResponse.StatusCode != http.StatusNotFound { - return fmt.Errorf("checking for presence of existing File %q (File Share %q / Storage Account %q / Resource Group %q): %s", fileName, storageShareId.Name, storageShareId.AccountName, account.ResourceGroup, err) + if !response.WasNotFound(existing.HttpResponse) { + return fmt.Errorf("checking for existing %s: %v", id, err) } } - if existing.HttpResponse.StatusCode != http.StatusNotFound { + if !response.WasNotFound(existing.HttpResponse) { return tf.ImportAsExistsError("azurerm_storage_share_file", id.ID()) } @@ -223,7 +224,7 @@ func resourceStorageShareFileUpdate(d *pluginsdk.ResourceData, meta interface{}) return fmt.Errorf("locating Storage Account %q", id.AccountId.AccountName) } - fileSharesClient, err := storageClient.FileSharesClient(ctx, *account) + fileSharesClient, err := storageClient.FileSharesDataPlaneClient(ctx, *account) if err != nil { return fmt.Errorf("building File Share Directories Client: %v", err) } @@ -236,14 +237,14 @@ func resourceStorageShareFileUpdate(d *pluginsdk.ResourceData, meta interface{}) return fmt.Errorf("unable to locate Storage Share %q", id.ShareName) } - client, err := storageClient.FileShareFilesClient(ctx, *account) + client, err := storageClient.FileShareFilesDataPlaneClient(ctx, *account) if err != nil { return fmt.Errorf("building File Share Files Client: %v", err) } existing, err := client.GetProperties(ctx, id.ShareName, id.DirectoryPath, id.FileName) if err != nil { - if existing.HttpResponse.StatusCode != http.StatusNotFound { + if !response.WasNotFound(existing.HttpResponse) { return fmt.Errorf("checking for presence of existing %s: %v", id, err) } } @@ -289,7 +290,7 @@ func resourceStorageShareFileRead(d *pluginsdk.ResourceData, meta interface{}) e return nil } - fileSharesClient, err := storageClient.FileSharesClient(ctx, *account) + fileSharesClient, err := storageClient.FileSharesDataPlaneClient(ctx, *account) if err != nil { return fmt.Errorf("building File Share Directories Client: %s", err) } @@ -304,7 +305,7 @@ func resourceStorageShareFileRead(d *pluginsdk.ResourceData, meta interface{}) e return nil } - client, err := storageClient.FileShareFilesClient(ctx, *account) + client, err := storageClient.FileShareFilesDataPlaneClient(ctx, *account) if err != nil { return fmt.Errorf("building File Share Client for Storage Account %s: %s", id.AccountId, err) } @@ -355,7 +356,7 @@ func resourceStorageShareFileDelete(d *pluginsdk.ResourceData, meta interface{}) return fmt.Errorf("locating Storage Account %q", id.AccountId.AccountName) } - client, err := storageClient.FileShareFilesClient(ctx, *account) + client, err := storageClient.FileShareFilesDataPlaneClient(ctx, *account) if err != nil { return fmt.Errorf("building File Share File Client for Storage Account %q (Resource Group %q): %v", id.AccountId.AccountName, account.ResourceGroup, err) } diff --git a/internal/services/storage/storage_share_file_resource_test.go b/internal/services/storage/storage_share_file_resource_test.go index b5c90a9c1c36..e51a6218a3a0 100644 --- a/internal/services/storage/storage_share_file_resource_test.go +++ b/internal/services/storage/storage_share_file_resource_test.go @@ -6,7 +6,7 @@ package storage_test import ( "context" "fmt" - "net/http" + "github.com/hashicorp/go-azure-helpers/lang/response" "os" "regexp" "testing" @@ -151,14 +151,14 @@ func (StorageShareFileResource) Exists(ctx context.Context, clients *clients.Cli return utils.Bool(false), nil } - client, err := clients.Storage.FileShareFilesClient(ctx, *account) + client, err := clients.Storage.FileShareFilesDataPlaneClient(ctx, *account) if err != nil { return nil, fmt.Errorf("building File Share Files Client: %s", err) } resp, err := client.GetProperties(ctx, id.ShareName, id.DirectoryPath, id.FileName) if err != nil { - if resp.HttpResponse.StatusCode != http.StatusNotFound { + if !response.WasNotFound(resp.HttpResponse) { return nil, fmt.Errorf("checking for presence of existing File %q (File Share %q / Storage Account %q / Resource Group %q): %s", id.FileName, id.ShareName, id.AccountId.AccountName, account.ResourceGroup, err) } } diff --git a/internal/services/storage/storage_share_resource.go b/internal/services/storage/storage_share_resource.go index f55bd992a5e4..11f0a4165f4a 100644 --- a/internal/services/storage/storage_share_resource.go +++ b/internal/services/storage/storage_share_resource.go @@ -11,6 +11,7 @@ import ( "github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2021-09-01/storage" // nolint: staticcheck "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/helpers" "github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/migration" "github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/validate" @@ -27,8 +28,8 @@ func resourceStorageShare() *pluginsdk.Resource { Update: resourceStorageShareUpdate, Delete: resourceStorageShareDelete, - Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.StorageShareDataPlaneID(id, "") // TODO: actual domain suffix needed here! + Importer: helpers.ImporterValidatingStorageResourceId(func(id, storageDomainSuffix string) error { + _, err := parse.StorageShareDataPlaneID(id, storageDomainSuffix) return err }), @@ -175,14 +176,14 @@ func resourceStorageShareCreate(d *pluginsdk.ResourceData, meta interface{}) err } } - client, err := storageClient.FileSharesClient(ctx, *account) + client, err := storageClient.FileSharesDataPlaneClient(ctx, *account) if err != nil { return fmt.Errorf("building File Share Client: %v", err) } exists, err := client.Exists(ctx, shareName) if err != nil { - return fmt.Errorf("checking for existence of existing %s: %v", id, err) + return fmt.Errorf("checking for existing %s: %v", id, err) } if exists != nil && *exists { return tf.ImportAsExistsError("azurerm_storage_share", id.ID()) @@ -233,7 +234,7 @@ func resourceStorageShareRead(d *pluginsdk.ResourceData, meta interface{}) error return nil } - client, err := storageClient.FileSharesClient(ctx, *account) + client, err := storageClient.FileSharesDataPlaneClient(ctx, *account) if err != nil { return fmt.Errorf("building File Share Client for Storage Account %q (Resource Group %q): %v", id.AccountName, account.ResourceGroup, err) } @@ -292,7 +293,7 @@ func resourceStorageShareUpdate(d *pluginsdk.ResourceData, meta interface{}) err return fmt.Errorf("locating Storage Account %q", id.AccountName) } - client, err := storageClient.FileSharesClient(ctx, *account) + client, err := storageClient.FileSharesDataPlaneClient(ctx, *account) if err != nil { return fmt.Errorf("building File Share Client for Storage Account %q (Resource Group %q): %v", id.AccountName, account.ResourceGroup, err) } @@ -366,7 +367,7 @@ func resourceStorageShareDelete(d *pluginsdk.ResourceData, meta interface{}) err return fmt.Errorf("locating Storage Account %q", id.AccountName) } - client, err := storageClient.FileSharesClient(ctx, *account) + client, err := storageClient.FileSharesDataPlaneClient(ctx, *account) if err != nil { return fmt.Errorf("building File Share Client for Storage Account %q (Resource Group %q): %v", id.AccountName, account.ResourceGroup, err) } diff --git a/internal/services/storage/storage_share_resource_test.go b/internal/services/storage/storage_share_resource_test.go index 1db65cd9399b..e9e5f2b8d48f 100644 --- a/internal/services/storage/storage_share_resource_test.go +++ b/internal/services/storage/storage_share_resource_test.go @@ -284,7 +284,7 @@ func (r StorageShareResource) Exists(ctx context.Context, client *clients.Client return nil, fmt.Errorf("unable to determine Account %q for Storage Share %q", id.AccountName, id.Name) } - sharesClient, err := client.Storage.FileSharesClient(ctx, *account) + sharesClient, err := client.Storage.FileSharesDataPlaneClient(ctx, *account) if err != nil { return nil, fmt.Errorf("building File Share Client for Storage Account %q (Resource Group %q): %+v", id.AccountName, account.ResourceGroup, err) } @@ -310,7 +310,7 @@ func (r StorageShareResource) Destroy(ctx context.Context, client *clients.Clien return nil, fmt.Errorf("unable to determine Account %q for Storage Share %q", id.AccountName, id.Name) } - sharesClient, err := client.Storage.FileSharesClient(ctx, *account) + sharesClient, err := client.Storage.FileSharesDataPlaneClient(ctx, *account) if err != nil { return nil, fmt.Errorf("building File Share Client for Storage Account %q (Resource Group %q): %+v", id.AccountName, account.ResourceGroup, err) } diff --git a/internal/services/storage/storage_table_entity_data_source.go b/internal/services/storage/storage_table_entity_data_source.go index a03e134c4982..d33a19021f20 100644 --- a/internal/services/storage/storage_table_entity_data_source.go +++ b/internal/services/storage/storage_table_entity_data_source.go @@ -78,7 +78,7 @@ func dataSourceStorageTableEntityRead(d *pluginsdk.ResourceData, meta interface{ return fmt.Errorf("the parent Storage Account %s was not found", accountName) } - client, err := storageClient.TableEntityClient(ctx, *account) + client, err := storageClient.TableEntityDataPlaneClient(ctx, *account) if err != nil { return fmt.Errorf("building Table Entity Client for Storage Account %q (Resource Group %q): %v", accountName, account.ResourceGroup, err) } diff --git a/internal/services/storage/storage_table_entity_resource.go b/internal/services/storage/storage_table_entity_resource.go index faed359cab42..ecbf570d5500 100644 --- a/internal/services/storage/storage_table_entity_resource.go +++ b/internal/services/storage/storage_table_entity_resource.go @@ -6,12 +6,13 @@ package storage import ( "fmt" "log" - "net/http" "strings" "time" + "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/helpers" "github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/validate" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" @@ -27,8 +28,8 @@ func resourceStorageTableEntity() *pluginsdk.Resource { Update: resourceStorageTableEntityCreateUpdate, Delete: resourceStorageTableEntityDelete, - Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := entities.ParseEntityID(id, "") // TODO: actual domain suffix needed here! + Importer: helpers.ImporterValidatingStorageResourceId(func(id, storageDomainSuffix string) error { + _, err := entities.ParseEntityID(id, storageDomainSuffix) return err }), @@ -107,7 +108,7 @@ func resourceStorageTableEntityCreateUpdate(d *pluginsdk.ResourceData, meta inte id := entities.NewEntityID(*accountId, tableName, partitionKey, rowKey) - client, err := storageClient.TableEntityClient(ctx, *account) + client, err := storageClient.TableEntityDataPlaneClient(ctx, *account) if err != nil { return fmt.Errorf("building Entity Client: %v", err) } @@ -120,12 +121,12 @@ func resourceStorageTableEntityCreateUpdate(d *pluginsdk.ResourceData, meta inte } existing, err := client.Get(ctx, tableName, input) if err != nil { - if existing.HttpResponse.StatusCode != http.StatusNotFound { - return fmt.Errorf("checking for presence of existing %s: %v", id, err) + if !response.WasNotFound(existing.HttpResponse) { + return fmt.Errorf("checking for existing %s: %v", id, err) } } - if existing.HttpResponse.StatusCode != http.StatusNotFound { + if !response.WasNotFound(existing.HttpResponse) { return tf.ImportAsExistsError("azurerm_storage_table_entity", id.ID()) } } @@ -165,7 +166,7 @@ func resourceStorageTableEntityRead(d *pluginsdk.ResourceData, meta interface{}) return nil } - client, err := storageClient.TableEntityClient(ctx, *account) + client, err := storageClient.TableEntityDataPlaneClient(ctx, *account) if err != nil { return fmt.Errorf("building Table Entity Client for Storage Account %q (Resource Group %q): %s", id.AccountId.AccountName, account.ResourceGroup, err) } @@ -211,7 +212,7 @@ func resourceStorageTableEntityDelete(d *pluginsdk.ResourceData, meta interface{ return fmt.Errorf("locating Storage Account %q", id.AccountId.AccountName) } - client, err := storageClient.TableEntityClient(ctx, *account) + client, err := storageClient.TableEntityDataPlaneClient(ctx, *account) if err != nil { return fmt.Errorf("building Entity Client for Storage Account %q (Resource Group %q): %s", id.AccountId.AccountName, account.ResourceGroup, err) } diff --git a/internal/services/storage/storage_table_entity_resource_test.go b/internal/services/storage/storage_table_entity_resource_test.go index bfa3303f767a..8948b1e8170c 100644 --- a/internal/services/storage/storage_table_entity_resource_test.go +++ b/internal/services/storage/storage_table_entity_resource_test.go @@ -6,7 +6,7 @@ package storage_test import ( "context" "fmt" - "net/http" + "github.com/hashicorp/go-azure-helpers/lang/response" "testing" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" @@ -129,7 +129,7 @@ func (r StorageTableEntityResource) Exists(ctx context.Context, client *clients. return nil, fmt.Errorf("storage Account %q was not found", id.AccountId.AccountName) } - entitiesClient, err := client.Storage.TableEntityClient(ctx, *account) + entitiesClient, err := client.Storage.TableEntityDataPlaneClient(ctx, *account) if err != nil { return nil, fmt.Errorf("building Table Entity Client: %+v", err) } @@ -141,7 +141,7 @@ func (r StorageTableEntityResource) Exists(ctx context.Context, client *clients. } resp, err := entitiesClient.Get(ctx, id.TableName, input) if err != nil { - if resp.HttpResponse.StatusCode == http.StatusNotFound { + if response.WasNotFound(resp.HttpResponse) { return utils.Bool(false), nil } return nil, fmt.Errorf("retrieving Entity (Partition Key %q / Row Key %q) (Table %q / Storage Account %q / Resource Group %q): %+v", id.PartitionKey, id.RowKey, id.TableName, id.AccountId.AccountName, account.ResourceGroup, err) diff --git a/internal/services/storage/storage_table_resource.go b/internal/services/storage/storage_table_resource.go index e84858ac2e4a..d6c88a78850c 100644 --- a/internal/services/storage/storage_table_resource.go +++ b/internal/services/storage/storage_table_resource.go @@ -10,6 +10,7 @@ import ( "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/helpers" "github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/migration" "github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/parse" "github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/validate" @@ -26,8 +27,8 @@ func resourceStorageTable() *pluginsdk.Resource { Delete: resourceStorageTableDelete, Update: resourceStorageTableUpdate, - Importer: pluginsdk.ImporterValidatingResourceId(func(id string) error { - _, err := parse.StorageTableDataPlaneID(id, "") // TODO: actual domain suffix needed here! + Importer: helpers.ImporterValidatingStorageResourceId(func(id, storageDomainSuffix string) error { + _, err := parse.StorageTableDataPlaneID(id, storageDomainSuffix) return err }), @@ -117,7 +118,7 @@ func resourceStorageTableCreate(d *pluginsdk.ResourceData, meta interface{}) err return fmt.Errorf("unable to locate Storage Account %q!", accountName) } - client, err := storageClient.TablesClient(ctx, *account) + client, err := storageClient.TablesDataPlaneClient(ctx, *account) if err != nil { return fmt.Errorf("building Table Client: %s", err) } @@ -126,7 +127,7 @@ func resourceStorageTableCreate(d *pluginsdk.ResourceData, meta interface{}) err exists, err := client.Exists(ctx, tableName) if err != nil { - return fmt.Errorf("checking for existence of existing %s: %v", id, err) + return fmt.Errorf("checking for existing %s: %v", id, err) } if exists != nil && *exists { return tf.ImportAsExistsError("azurerm_storage_table", id.ID()) @@ -165,7 +166,7 @@ func resourceStorageTableRead(d *pluginsdk.ResourceData, meta interface{}) error return nil } - client, err := storageClient.TablesClient(ctx, *account) + client, err := storageClient.TablesDataPlaneClient(ctx, *account) if err != nil { return fmt.Errorf("building Tables Client: %v", err) } @@ -213,7 +214,7 @@ func resourceStorageTableDelete(d *pluginsdk.ResourceData, meta interface{}) err return fmt.Errorf("locating Storage Account %q", id.AccountName) } - client, err := storageClient.TablesClient(ctx, *account) + client, err := storageClient.TablesDataPlaneClient(ctx, *account) if err != nil { return fmt.Errorf("building Tables Client: %v", err) } @@ -243,7 +244,7 @@ func resourceStorageTableUpdate(d *pluginsdk.ResourceData, meta interface{}) err return fmt.Errorf("locating Storage Account %q", id.AccountName) } - client, err := storageClient.TablesClient(ctx, *account) + client, err := storageClient.TablesDataPlaneClient(ctx, *account) if err != nil { return fmt.Errorf("building Table Client: %v", err) } diff --git a/internal/services/storage/storage_table_resource_test.go b/internal/services/storage/storage_table_resource_test.go index 735b9995dbdc..6a76e3b9040f 100644 --- a/internal/services/storage/storage_table_resource_test.go +++ b/internal/services/storage/storage_table_resource_test.go @@ -94,7 +94,7 @@ func (r StorageTableResource) Exists(ctx context.Context, client *clients.Client if account == nil { return nil, fmt.Errorf("unable to determine Resource Group for Storage Storage Table %q (Account %q)", id.Name, id.AccountName) } - tablesClient, err := client.Storage.TablesClient(ctx, *account) + tablesClient, err := client.Storage.TablesDataPlaneClient(ctx, *account) if err != nil { return nil, fmt.Errorf("building Table Client: %+v", err) } @@ -114,7 +114,7 @@ func (r StorageTableResource) Destroy(ctx context.Context, client *clients.Clien if account == nil { return nil, fmt.Errorf("unable to determine Resource Group for Storage Storage Table %q (Account %q)", id.Name, id.AccountName) } - tablesClient, err := client.Storage.TablesClient(ctx, *account) + tablesClient, err := client.Storage.TablesDataPlaneClient(ctx, *account) if err != nil { return nil, fmt.Errorf("building Table Client: %+v", err) } diff --git a/internal/services/storage/validate/storage_container.go b/internal/services/storage/validate/storage_container.go index 365e785a3495..616293abde83 100644 --- a/internal/services/storage/validate/storage_container.go +++ b/internal/services/storage/validate/storage_container.go @@ -5,6 +5,7 @@ package validate import ( "fmt" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "regexp" "github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/parse" @@ -29,16 +30,18 @@ func StorageContainerName(v interface{}, k string) (warnings []string, errors [] return warnings, errors } -func StorageContainerDataPlaneID(input interface{}, key string) (warnings []string, errors []error) { - v, ok := input.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected %q to be a string", key)) - return - } +func StorageContainerDataPlaneIDForDomainSuffix(domainSuffix string) pluginsdk.SchemaValidateFunc { + return func(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } - if _, err := parse.StorageContainerDataPlaneID(v); err != nil { - errors = append(errors, err) - } + if _, err := parse.StorageContainerDataPlaneID(v, domainSuffix); err != nil { + errors = append(errors, err) + } - return + return + } } diff --git a/internal/services/storage/validate/storage_share_name.go b/internal/services/storage/validate/storage_share_name.go index b79e4ee93606..50acc7e064f2 100644 --- a/internal/services/storage/validate/storage_share_name.go +++ b/internal/services/storage/validate/storage_share_name.go @@ -5,6 +5,7 @@ package validate import ( "fmt" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" "regexp" "github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/parse" @@ -34,17 +35,19 @@ func StorageShareName(v interface{}, k string) (warnings []string, errors []erro return warnings, errors } -func StorageShareID(i interface{}, k string) (warnings []string, errors []error) { - v, ok := i.(string) - if !ok { - errors = append(errors, fmt.Errorf("expected type of %q to be string", k)) - return - } +func StorageShareIDForDomainSuffix(domainSuffix string) pluginsdk.SchemaValidateFunc { + return func(i interface{}, k string) (warnings []string, errors []error) { + v, ok := i.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected type of %q to be string", k)) + return + } - if _, err := parse.StorageShareDataPlaneID(v); err != nil { - errors = append(errors, fmt.Errorf("Can not parse %q as a resource id: %v", k, err)) - return - } + if _, err := parse.StorageShareDataPlaneID(v, domainSuffix); err != nil { + errors = append(errors, fmt.Errorf("Can not parse %q as a resource id: %v", k, err)) + return + } - return warnings, errors + return warnings, errors + } } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts/get_service_properties.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts/get_service_properties.go index 01ea987863cc..fce040b887a2 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts/get_service_properties.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts/get_service_properties.go @@ -9,13 +9,13 @@ import ( ) type GetServicePropertiesResult struct { - HttpResponse *client.Response - Model *StorageServiceProperties + StorageServiceProperties + HttpResponse *http.Response } -func (c Client) GetServiceProperties(ctx context.Context, accountName string) (resp GetServicePropertiesResult, err error) { +func (c Client) GetServiceProperties(ctx context.Context, accountName string) (result GetServicePropertiesResult, err error) { if accountName == "" { - return resp, fmt.Errorf("`accountName` cannot be an empty string") + return result, fmt.Errorf("`accountName` cannot be an empty string") } opts := client.RequestOptions{ @@ -27,23 +27,28 @@ func (c Client) GetServiceProperties(ctx context.Context, accountName string) (r OptionsObject: servicePropertiesOptions{}, Path: "/", } + req, err := c.Client.NewRequest(ctx, opts) if err != nil { err = fmt.Errorf("building request: %+v", err) return } - resp.HttpResponse, err = req.Execute(ctx) - if err != nil { - err = fmt.Errorf("executing request: %+v", err) - return - } - if resp.HttpResponse != nil { - if err = resp.HttpResponse.Unmarshal(&resp.Model); err != nil { - err = fmt.Errorf("unmarshaling response: %+v", err) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + err = resp.Unmarshal(&result) + if err != nil { + err = fmt.Errorf("unmarshalling response: %+v", err) return } } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } return } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts/set_service_properties.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts/set_service_properties.go index 173a80f0f7d9..5252dc021eda 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts/set_service_properties.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts/set_service_properties.go @@ -9,12 +9,12 @@ import ( ) type SetServicePropertiesResult struct { - HttpResponse *client.Response + HttpResponse *http.Response } -func (c Client) SetServiceProperties(ctx context.Context, accountName string, input StorageServiceProperties) (resp SetServicePropertiesResult, err error) { +func (c Client) SetServiceProperties(ctx context.Context, accountName string, input StorageServiceProperties) (result SetServicePropertiesResult, err error) { if accountName == "" { - return resp, fmt.Errorf("`accountName` cannot be an empty string") + return result, fmt.Errorf("`accountName` cannot be an empty string") } opts := client.RequestOptions{ @@ -26,16 +26,23 @@ func (c Client) SetServiceProperties(ctx context.Context, accountName string, in OptionsObject: servicePropertiesOptions{}, Path: "/", } + req, err := c.Client.NewRequest(ctx, opts) if err != nil { err = fmt.Errorf("building request: %+v", err) return } + if err = req.Marshal(&input); err != nil { err = fmt.Errorf("marshaling request: %+v", err) return } - resp.HttpResponse, err = req.Execute(ctx) + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/README.md b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/README.md index f1a23a56c062..276ddc384d4d 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/README.md +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/README.md @@ -30,7 +30,7 @@ func Example() error { blobClient, err := blobs.NewWithBaseUri(fmt.Sprintf("https://%s.blob.%s", accountName, domainSuffix)) if err != nil { - return fmt.Errorf("building client for environment: %+v", err) + return fmt.Errorf("building client for environment: %v", err) } auth, err := auth.NewSharedKeyAuthorizer(accountName, storageAccountKey, auth.SharedKey) diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/append_block.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/append_block.go index a1068d459c5c..e3f638ec0fd7 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/append_block.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/append_block.go @@ -46,7 +46,7 @@ type AppendBlockInput struct { } type AppendBlockResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response BlobAppendOffset string BlobCommittedBlockCount int64 @@ -56,22 +56,25 @@ type AppendBlockResponse struct { } // AppendBlock commits a new block of data to the end of an existing append blob. -func (c Client) AppendBlock(ctx context.Context, containerName, blobName string, input AppendBlockInput) (resp AppendBlockResponse, err error) { - +func (c Client) AppendBlock(ctx context.Context, containerName, blobName string, input AppendBlockInput) (result AppendBlockResponse, err error) { if containerName == "" { - return resp, fmt.Errorf("`containerName` cannot be an empty string") + err = fmt.Errorf("`containerName` cannot be an empty string") + return } if strings.ToLower(containerName) != containerName { - return resp, fmt.Errorf("`containerName` must be a lower-cased string") + err = fmt.Errorf("`containerName` must be a lower-cased string") + return } if blobName == "" { - return resp, fmt.Errorf("`blobName` cannot be an empty string") + err = fmt.Errorf("`blobName` cannot be an empty string") + return } if input.Content != nil && len(*input.Content) > (4*1024*1024) { - return resp, fmt.Errorf("`input.Content` must be at most 4MB") + err = fmt.Errorf("`input.Content` must be at most 4MB") + return } opts := client.RequestOptions{ @@ -97,30 +100,31 @@ func (c Client) AppendBlock(ctx context.Context, containerName, blobName string, req.ContentLength = int64(len(*input.Content)) - resp.HttpResponse, err = req.Execute(ctx) - if err != nil { - err = fmt.Errorf("executing request: %+v", err) - return - } + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response - if resp.HttpResponse != nil { - if resp.HttpResponse.Header != nil { - resp.BlobAppendOffset = resp.HttpResponse.Header.Get("x-ms-blob-append-offset") - resp.ContentMD5 = resp.HttpResponse.Header.Get("Content-MD5") - resp.ETag = resp.HttpResponse.Header.Get("ETag") - resp.LastModified = resp.HttpResponse.Header.Get("Last-Modified") + 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") + result.LastModified = resp.Header.Get("Last-Modified") - if v := resp.HttpResponse.Header.Get("x-ms-blob-committed-block-count"); v != "" { + if v := resp.Header.Get("x-ms-blob-committed-block-count"); v != "" { i, innerErr := strconv.Atoi(v) if innerErr != nil { - err = fmt.Errorf("error parsing %q as an integer: %s", v, innerErr) + err = fmt.Errorf("parsing `x-ms-blob-committed-block-count` header value %q: %+v", v, innerErr) return } - resp.BlobCommittedBlockCount = int64(i) + result.BlobCommittedBlockCount = int64(i) } - } } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } return } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/copy.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/copy.go index 2ff309cc75da..3687c101aec0 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/copy.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/copy.go @@ -106,29 +106,28 @@ type CopyInput struct { } type CopyResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response CopyID string CopyStatus string } // Copy copies a blob to a destination within the storage account asynchronously. -func (c Client) Copy(ctx context.Context, containerName, blobName string, input CopyInput) (resp CopyResponse, err error) { - +func (c Client) Copy(ctx context.Context, containerName, blobName string, input CopyInput) (result CopyResponse, err error) { if containerName == "" { - return resp, fmt.Errorf("`containerName` cannot be an empty string") + return result, fmt.Errorf("`containerName` cannot be an empty string") } if strings.ToLower(containerName) != containerName { - return resp, fmt.Errorf("`containerName` must be a lower-cased string") + return result, fmt.Errorf("`containerName` must be a lower-cased string") } if blobName == "" { - return resp, fmt.Errorf("`blobName` cannot be an empty string") + return result, fmt.Errorf("`blobName` cannot be an empty string") } if input.CopySource == "" { - return resp, fmt.Errorf("`input.CopySource` cannot be an empty string") + return result, fmt.Errorf("`input.CopySource` cannot be an empty string") } opts := client.RequestOptions{ @@ -148,19 +147,21 @@ func (c Client) Copy(ctx context.Context, containerName, blobName string, input return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if resp.Header != nil { + result.CopyID = resp.Header.Get("x-ms-copy-id") + result.CopyStatus = resp.Header.Get("x-ms-copy-status") + } + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return } - if resp.HttpResponse != nil { - if resp.HttpResponse.Header != nil { - resp.CopyID = resp.HttpResponse.Header.Get("x-ms-copy-id") - resp.CopyStatus = resp.HttpResponse.Header.Get("x-ms-copy-status") - } - } - return } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/copy_abort.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/copy_abort.go index 064c56f09ab8..5d9469a5097c 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/copy_abort.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/copy_abort.go @@ -20,26 +20,29 @@ type AbortCopyInput struct { } type CopyAbortResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } // AbortCopy aborts a pending Copy Blob operation, and leaves a destination blob with zero length and full metadata. -func (c Client) AbortCopy(ctx context.Context, containerName, blobName string, input AbortCopyInput) (resp CopyAbortResponse, err error) { - +func (c Client) AbortCopy(ctx context.Context, containerName, blobName string, input AbortCopyInput) (result CopyAbortResponse, err error) { if containerName == "" { - return resp, fmt.Errorf("`containerName` cannot be an empty string") + err = fmt.Errorf("`containerName` cannot be an empty string") + return } if strings.ToLower(containerName) != containerName { - return resp, fmt.Errorf("`containerName` must be a lower-cased string") + err = fmt.Errorf("`containerName` must be a lower-cased string") + return } if blobName == "" { - return resp, fmt.Errorf("`blobName` cannot be an empty string") + err = fmt.Errorf("`blobName` cannot be an empty string") + return } if input.CopyID == "" { - return resp, fmt.Errorf("`input.CopyID` cannot be an empty string") + err = fmt.Errorf("`input.CopyID` cannot be an empty string") + return } opts := client.RequestOptions{ @@ -59,7 +62,11 @@ func (c Client) AbortCopy(ctx context.Context, containerName, blobName string, i return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/delete.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/delete.go index e13aaa599fe6..80c1e4332389 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/delete.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/delete.go @@ -21,22 +21,21 @@ type DeleteInput struct { } type DeleteResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } // Delete marks the specified blob or snapshot for deletion. The blob is later deleted during garbage collection. -func (c Client) Delete(ctx context.Context, containerName, blobName string, input DeleteInput) (resp DeleteResponse, err error) { - +func (c Client) Delete(ctx context.Context, containerName, blobName string, input DeleteInput) (result DeleteResponse, err error) { if containerName == "" { - return resp, fmt.Errorf("`containerName` cannot be an empty string") + return result, fmt.Errorf("`containerName` cannot be an empty string") } if strings.ToLower(containerName) != containerName { - return resp, fmt.Errorf("`containerName` must be a lower-cased string") + return result, fmt.Errorf("`containerName` must be a lower-cased string") } if blobName == "" { - return resp, fmt.Errorf("`blobName` cannot be an empty string") + return result, fmt.Errorf("`blobName` cannot be an empty string") } opts := client.RequestOptions{ @@ -56,7 +55,11 @@ func (c Client) Delete(ctx context.Context, containerName, blobName string, inpu return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/delete_snapshot.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/delete_snapshot.go index 0407eb1f7829..e5cfa3c8f0b6 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/delete_snapshot.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/delete_snapshot.go @@ -20,26 +20,29 @@ type DeleteSnapshotInput struct { } type DeleteSnapshotResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } // DeleteSnapshot marks a single Snapshot of a Blob for Deletion based on it's DateTime, which will be deleted during the next Garbage Collection cycle. -func (c Client) DeleteSnapshot(ctx context.Context, containerName, blobName string, input DeleteSnapshotInput) (resp DeleteSnapshotResponse, err error) { - +func (c Client) DeleteSnapshot(ctx context.Context, containerName, blobName string, input DeleteSnapshotInput) (result DeleteSnapshotResponse, err error) { if containerName == "" { - return resp, fmt.Errorf("`containerName` cannot be an empty string") + err = fmt.Errorf("`containerName` cannot be an empty string") + return } if strings.ToLower(containerName) != containerName { - return resp, fmt.Errorf("`containerName` must be a lower-cased string") + err = fmt.Errorf("`containerName` must be a lower-cased string") + return } if blobName == "" { - return resp, fmt.Errorf("`blobName` cannot be an empty string") + err = fmt.Errorf("`blobName` cannot be an empty string") + return } if input.SnapshotDateTime == "" { - return resp, fmt.Errorf("`input.SnapshotDateTime` cannot be an empty string") + err = fmt.Errorf("`input.SnapshotDateTime` cannot be an empty string") + return } opts := client.RequestOptions{ @@ -59,7 +62,11 @@ func (c Client) DeleteSnapshot(ctx context.Context, containerName, blobName stri return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/delete_snapshots.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/delete_snapshots.go index 34b3beb623a8..dd0ce7be20fc 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/delete_snapshots.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/delete_snapshots.go @@ -17,22 +17,24 @@ type DeleteSnapshotsInput struct { } type DeleteSnapshotsResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } // DeleteSnapshots marks all Snapshots of a Blob for Deletion, which will be deleted during the next Garbage Collection Cycle. -func (c Client) DeleteSnapshots(ctx context.Context, containerName, blobName string, input DeleteSnapshotsInput) (resp DeleteSnapshotsResponse, err error) { - +func (c Client) DeleteSnapshots(ctx context.Context, containerName, blobName string, input DeleteSnapshotsInput) (result DeleteSnapshotsResponse, err error) { if containerName == "" { - return resp, fmt.Errorf("`containerName` cannot be an empty string") + err = fmt.Errorf("`containerName` cannot be an empty string") + return } if strings.ToLower(containerName) != containerName { - return resp, fmt.Errorf("`containerName` must be a lower-cased string") + err = fmt.Errorf("`containerName` must be a lower-cased string") + return } if blobName == "" { - return resp, fmt.Errorf("`blobName` cannot be an empty string") + err = fmt.Errorf("`blobName` cannot be an empty string") + return } opts := client.RequestOptions{ @@ -52,7 +54,11 @@ func (c Client) DeleteSnapshots(ctx context.Context, containerName, blobName str return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/get.go index 0f5572a8b9c2..c108a3269b23 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/get.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/get.go @@ -17,32 +17,31 @@ type GetInput struct { } type GetResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response Contents []byte } // Get reads or downloads a blob from the system, including its metadata and properties. -func (c Client) Get(ctx context.Context, containerName, blobName string, input GetInput) (resp GetResponse, err error) { - +func (c Client) Get(ctx context.Context, containerName, blobName string, input GetInput) (result GetResponse, err error) { if containerName == "" { - return resp, fmt.Errorf("`containerName` cannot be an empty string") + return result, fmt.Errorf("`containerName` cannot be an empty string") } if strings.ToLower(containerName) != containerName { - return resp, fmt.Errorf("`containerName` must be a lower-cased string") + return result, fmt.Errorf("`containerName` must be a lower-cased string") } if blobName == "" { - return resp, fmt.Errorf("`blobName` cannot be an empty string") + return result, fmt.Errorf("`blobName` cannot be an empty string") } if input.LeaseID != nil && *input.LeaseID == "" { - return resp, fmt.Errorf("`input.LeaseID` should either be specified or nil, not an empty string") + return result, fmt.Errorf("`input.LeaseID` should either be specified or nil, not an empty string") } if (input.StartByte != nil && input.EndByte == nil) || input.StartByte == nil && input.EndByte != nil { - return resp, fmt.Errorf("`input.StartByte` and `input.EndByte` must both be specified, or both be nil") + return result, fmt.Errorf("`input.StartByte` and `input.EndByte` must both be specified, or both be nil") } opts := client.RequestOptions{ @@ -63,18 +62,21 @@ func (c Client) Get(ctx context.Context, containerName, blobName string, input G return } - resp.HttpResponse, err = req.Execute(ctx) - if err != nil { - err = fmt.Errorf("executing request: %+v", err) - return - } + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response - if resp.HttpResponse != nil { - err = resp.HttpResponse.Unmarshal(&resp.Contents) + err = resp.Unmarshal(&result.Contents) if err != nil { - return resp, fmt.Errorf("unmarshalling response: %v", err) + err = fmt.Errorf("unmarshalling response: %+v", err) + return } } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } return } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/get_block_list.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/get_block_list.go index 9a783cb6ebac..b7c4037d88f0 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/get_block_list.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/get_block_list.go @@ -17,7 +17,7 @@ type GetBlockListInput struct { } type GetBlockListResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response // The size of the blob in bytes BlobContentLength *int64 @@ -36,18 +36,17 @@ type GetBlockListResponse struct { } // GetBlockList retrieves the list of blocks that have been uploaded as part of a block blob. -func (c Client) GetBlockList(ctx context.Context, containerName, blobName string, input GetBlockListInput) (resp GetBlockListResponse, err error) { - +func (c Client) GetBlockList(ctx context.Context, containerName, blobName string, input GetBlockListInput) (result GetBlockListResponse, err error) { if containerName == "" { - return resp, fmt.Errorf("`containerName` cannot be an empty string") + return result, fmt.Errorf("`containerName` cannot be an empty string") } if strings.ToLower(containerName) != containerName { - return resp, fmt.Errorf("`containerName` must be a lower-cased string") + return result, fmt.Errorf("`containerName` must be a lower-cased string") } if blobName == "" { - return resp, fmt.Errorf("`blobName` cannot be an empty string") + return result, fmt.Errorf("`blobName` cannot be an empty string") } opts := client.RequestOptions{ @@ -67,33 +66,37 @@ func (c Client) GetBlockList(ctx context.Context, containerName, blobName string return } - resp.HttpResponse, err = req.Execute(ctx) - if err != nil { - err = fmt.Errorf("executing request: %+v", err) - return - } + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response - if resp.HttpResponse != nil { - if resp.HttpResponse.Header != nil { - resp.ContentType = resp.HttpResponse.Header.Get("Content-Type") - resp.ETag = resp.HttpResponse.Header.Get("ETag") + if resp.Header != nil { + result.ContentType = resp.Header.Get("Content-Type") + result.ETag = resp.Header.Get("ETag") - if v := resp.HttpResponse.Header.Get("x-ms-blob-content-length"); v != "" { + if v := resp.Header.Get("x-ms-blob-content-length"); v != "" { i, innerErr := strconv.Atoi(v) if innerErr != nil { - err = fmt.Errorf("error parsing %q as an integer: %s", v, innerErr) + err = fmt.Errorf("parsing `x-ms-blob-content-length` header value %q: %s", v, innerErr) return } i64 := int64(i) - resp.BlobContentLength = &i64 + result.BlobContentLength = &i64 } } - err = resp.HttpResponse.Unmarshal(&resp) + + err = resp.Unmarshal(&result) if err != nil { - return resp, fmt.Errorf("unmarshalling response: %v", err) + err = fmt.Errorf("unmarshalling response: %+v", err) + return } } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } return } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/get_page_ranges.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/get_page_ranges.go index 6d0f54163eaa..fe83294cc0b3 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/get_page_ranges.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/get_page_ranges.go @@ -19,7 +19,7 @@ type GetPageRangesInput struct { } type GetPageRangesResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response // The size of the blob in bytes ContentLength *int64 @@ -42,22 +42,21 @@ type PageRange struct { } // GetPageRanges returns the list of valid page ranges for a page blob or snapshot of a page blob. -func (c Client) GetPageRanges(ctx context.Context, containerName, blobName string, input GetPageRangesInput) (resp GetPageRangesResponse, err error) { - +func (c Client) GetPageRanges(ctx context.Context, containerName, blobName string, input GetPageRangesInput) (result GetPageRangesResponse, err error) { if containerName == "" { - return resp, fmt.Errorf("`containerName` cannot be an empty string") + return result, fmt.Errorf("`containerName` cannot be an empty string") } if strings.ToLower(containerName) != containerName { - return resp, fmt.Errorf("`containerName` must be a lower-cased string") + return result, fmt.Errorf("`containerName` must be a lower-cased string") } if blobName == "" { - return resp, fmt.Errorf("`blobName` cannot be an empty string") + return result, fmt.Errorf("`blobName` cannot be an empty string") } - if (input.StartByte != nil && input.EndByte == nil) || input.StartByte == nil && input.EndByte != nil { - return resp, fmt.Errorf("`input.StartByte` and `input.EndByte` must both be specified, or both be nil") + if (input.StartByte != nil && input.EndByte == nil) || (input.StartByte == nil && input.EndByte != nil) { + return result, fmt.Errorf("`input.StartByte` and `input.EndByte` must both be specified, or both be nil") } opts := client.RequestOptions{ @@ -77,34 +76,37 @@ func (c Client) GetPageRanges(ctx context.Context, containerName, blobName strin return } - resp.HttpResponse, err = req.Execute(ctx) - if err != nil { - err = fmt.Errorf("executing request: %+v", err) - return - } + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response - if resp.HttpResponse != nil { - if resp.HttpResponse.Header != nil { - resp.ContentType = resp.HttpResponse.Header.Get("Content-Type") - resp.ETag = resp.HttpResponse.Header.Get("ETag") + if resp.Header != nil { + result.ContentType = resp.Header.Get("Content-Type") + result.ETag = resp.Header.Get("ETag") - if v := resp.HttpResponse.Header.Get("x-ms-blob-content-length"); v != "" { + if v := resp.Header.Get("x-ms-blob-content-length"); v != "" { i, innerErr := strconv.Atoi(v) if innerErr != nil { - err = fmt.Errorf("Error parsing %q as an integer: %s", v, innerErr) + err = fmt.Errorf("parsing `x-ms-blob-content-length` header value %q: %+v", v, innerErr) return } i64 := int64(i) - resp.ContentLength = &i64 + result.ContentLength = &i64 } } - err = resp.HttpResponse.Unmarshal(&resp) + err = resp.Unmarshal(&result) if err != nil { - return resp, fmt.Errorf("unmarshalling response: %s", err) + err = fmt.Errorf("unmarshalling response: %+v", err) + return } } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } return } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/incremental_copy_blob.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/incremental_copy_blob.go index d059f11e2bc7..0423c0f99e22 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/incremental_copy_blob.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/incremental_copy_blob.go @@ -19,29 +19,32 @@ type IncrementalCopyBlobInput struct { } type IncrementalCopyBlob struct { - HttpResponse *client.Response + HttpResponse *http.Response } // IncrementalCopyBlob copies a snapshot of the source page blob to a destination page blob. // The snapshot is copied such that only the differential changes between the previously copied // snapshot are transferred to the destination. // The copied snapshots are complete copies of the original snapshot and can be read or copied from as usual. -func (c Client) IncrementalCopyBlob(ctx context.Context, containerName, blobName string, input IncrementalCopyBlobInput) (resp IncrementalCopyBlob, err error) { - +func (c Client) IncrementalCopyBlob(ctx context.Context, containerName, blobName string, input IncrementalCopyBlobInput) (result IncrementalCopyBlob, err error) { if containerName == "" { - return resp, fmt.Errorf("`containerName` cannot be an empty string") + err = fmt.Errorf("`containerName` cannot be an empty string") + return } if strings.ToLower(containerName) != containerName { - return resp, fmt.Errorf("`containerName` must be a lower-cased string") + err = fmt.Errorf("`containerName` must be a lower-cased string") + return } if blobName == "" { - return resp, fmt.Errorf("`blobName` cannot be an empty string") + err = fmt.Errorf("`blobName` cannot be an empty string") + return } if input.CopySource == "" { - return resp, fmt.Errorf("`input.CopySource` cannot be an empty string") + err = fmt.Errorf("`input.CopySource` cannot be an empty string") + return } opts := client.RequestOptions{ @@ -61,7 +64,11 @@ func (c Client) IncrementalCopyBlob(ctx context.Context, containerName, blobName return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/lease_acquire.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/lease_acquire.go index 214808ca0713..d4477564eacc 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/lease_acquire.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/lease_acquire.go @@ -24,36 +24,41 @@ type AcquireLeaseInput struct { } type AcquireLeaseResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response LeaseID string } // AcquireLease establishes and manages a lock on a blob for write and delete operations. -func (c Client) AcquireLease(ctx context.Context, containerName, blobName string, input AcquireLeaseInput) (resp AcquireLeaseResponse, err error) { - +func (c Client) AcquireLease(ctx context.Context, containerName, blobName string, input AcquireLeaseInput) (result AcquireLeaseResponse, err error) { if containerName == "" { - return resp, fmt.Errorf("`containerName` cannot be an empty string") + err = fmt.Errorf("`containerName` cannot be an empty string") + return } if strings.ToLower(containerName) != containerName { - return resp, fmt.Errorf("`containerName` must be a lower-cased string") + err = fmt.Errorf("`containerName` must be a lower-cased string") + return } if blobName == "" { - return resp, fmt.Errorf("`blobName` cannot be an empty string") + err = fmt.Errorf("`blobName` cannot be an empty string") + return } if input.LeaseID != nil && *input.LeaseID == "" { - return resp, fmt.Errorf("`input.LeaseID` cannot be an empty string, if specified") + err = fmt.Errorf("`input.LeaseID` cannot be an empty string, if specified") + return } if input.ProposedLeaseID != nil && *input.ProposedLeaseID == "" { - return resp, fmt.Errorf("`input.ProposedLeaseID` cannot be an empty string, if specified") + err = fmt.Errorf("`input.ProposedLeaseID` cannot be an empty string, if specified") + return } // An infinite lease duration is -1 seconds. A non-infinite lease can be between 15 and 60 seconds if input.LeaseDuration != -1 && (input.LeaseDuration <= 15 || input.LeaseDuration >= 60) { - return resp, fmt.Errorf("`input.LeaseDuration` must be -1 (infinite), or between 15 and 60 seconds") + err = fmt.Errorf("`input.LeaseDuration` must be -1 (infinite), or between 15 and 60 seconds") + return } opts := client.RequestOptions{ @@ -73,18 +78,20 @@ func (c Client) AcquireLease(ctx context.Context, containerName, blobName string return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if resp.Header != nil { + result.LeaseID = resp.Header.Get("x-ms-lease-id") + } + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return } - if resp.HttpResponse != nil { - if resp.HttpResponse.Header != nil { - resp.LeaseID = resp.HttpResponse.Header.Get("x-ms-lease-id") - } - } - return } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/lease_break.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/lease_break.go index 858c3061793f..74e689106694 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/lease_break.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/lease_break.go @@ -26,7 +26,7 @@ type BreakLeaseInput struct { } type BreakLeaseResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response // Approximate time remaining in the lease period, in seconds. // If the break is immediate, 0 is returned. @@ -34,22 +34,25 @@ type BreakLeaseResponse struct { } // BreakLease breaks an existing lock on a blob using the LeaseID. -func (c Client) BreakLease(ctx context.Context, containerName, blobName string, input BreakLeaseInput) (resp BreakLeaseResponse, err error) { - +func (c Client) BreakLease(ctx context.Context, containerName, blobName string, input BreakLeaseInput) (result BreakLeaseResponse, err error) { if containerName == "" { - return resp, fmt.Errorf("`containerName` cannot be an empty string") + err = fmt.Errorf("`containerName` cannot be an empty string") + return } if strings.ToLower(containerName) != containerName { - return resp, fmt.Errorf("`containerName` must be a lower-cased string") + err = fmt.Errorf("`containerName` must be a lower-cased string") + return } if blobName == "" { - return resp, fmt.Errorf("`blobName` cannot be an empty string") + err = fmt.Errorf("`blobName` cannot be an empty string") + return } if input.LeaseID == "" { - return resp, fmt.Errorf("`input.LeaseID` cannot be an empty string") + err = fmt.Errorf("`input.LeaseID` cannot be an empty string") + return } opts := client.RequestOptions{ @@ -69,7 +72,11 @@ func (c Client) BreakLease(ctx context.Context, containerName, blobName string, return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/lease_change.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/lease_change.go index c69d05483b89..f983d1dd9c6c 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/lease_change.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/lease_change.go @@ -16,32 +16,36 @@ type ChangeLeaseInput struct { } type ChangeLeaseResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response LeaseID string } // ChangeLease changes an existing lock on a blob for another lock. -func (c Client) ChangeLease(ctx context.Context, containerName, blobName string, input ChangeLeaseInput) (resp ChangeLeaseResponse, err error) { - +func (c Client) ChangeLease(ctx context.Context, containerName, blobName string, input ChangeLeaseInput) (result ChangeLeaseResponse, err error) { if containerName == "" { - return resp, fmt.Errorf("`containerName` cannot be an empty string") + err = fmt.Errorf("`containerName` cannot be an empty string") + return } if strings.ToLower(containerName) != containerName { - return resp, fmt.Errorf("`containerName` must be a lower-cased string") + err = fmt.Errorf("`containerName` must be a lower-cased string") + return } if blobName == "" { - return resp, fmt.Errorf("`blobName` cannot be an empty string") + err = fmt.Errorf("`blobName` cannot be an empty string") + return } if input.ExistingLeaseID == "" { - return resp, fmt.Errorf("`input.ExistingLeaseID` cannot be an empty string") + err = fmt.Errorf("`input.ExistingLeaseID` cannot be an empty string") + return } if input.ProposedLeaseID == "" { - return resp, fmt.Errorf("`input.ProposedLeaseID` cannot be an empty string") + err = fmt.Errorf("`input.ProposedLeaseID` cannot be an empty string") + return } opts := client.RequestOptions{ @@ -61,18 +65,20 @@ func (c Client) ChangeLease(ctx context.Context, containerName, blobName string, return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if resp.Header != nil { + result.LeaseID = resp.Header.Get("x-ms-lease-id") + } + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return } - if resp.HttpResponse != nil { - if resp.HttpResponse.Header != nil { - resp.LeaseID = resp.HttpResponse.Header.Get("x-ms-lease-id") - } - } - return } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/lease_release.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/lease_release.go index 350493da229b..2101828b24e1 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/lease_release.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/lease_release.go @@ -11,7 +11,7 @@ import ( ) type ReleaseLeaseResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } type ReleaseLeaseInput struct { @@ -19,22 +19,25 @@ type ReleaseLeaseInput struct { } // ReleaseLease releases a lock based on the Lease ID. -func (c Client) ReleaseLease(ctx context.Context, containerName, blobName string, input ReleaseLeaseInput) (resp ReleaseLeaseResponse, err error) { - +func (c Client) ReleaseLease(ctx context.Context, containerName, blobName string, input ReleaseLeaseInput) (result ReleaseLeaseResponse, err error) { if containerName == "" { - return resp, fmt.Errorf("`containerName` cannot be an empty string") + err = fmt.Errorf("`containerName` cannot be an empty string") + return } if strings.ToLower(containerName) != containerName { - return resp, fmt.Errorf("`containerName` must be a lower-cased string") + err = fmt.Errorf("`containerName` must be a lower-cased string") + return } if blobName == "" { - return resp, fmt.Errorf("`blobName` cannot be an empty string") + err = fmt.Errorf("`blobName` cannot be an empty string") + return } if input.LeaseID == "" { - return resp, fmt.Errorf("`input.LeaseID` cannot be an empty string") + err = fmt.Errorf("`input.LeaseID` cannot be an empty string") + return } opts := client.RequestOptions{ @@ -54,7 +57,11 @@ func (c Client) ReleaseLease(ctx context.Context, containerName, blobName string return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/lease_renew.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/lease_renew.go index 2a82a0af2a9e..e43a12d96ea9 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/lease_renew.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/lease_renew.go @@ -11,29 +11,32 @@ import ( ) type RenewLeaseResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } type RenewLeaseInput struct { LeaseID string } -func (c Client) RenewLease(ctx context.Context, containerName, blobName string, input RenewLeaseInput) (resp RenewLeaseResponse, err error) { - +func (c Client) RenewLease(ctx context.Context, containerName, blobName string, input RenewLeaseInput) (result RenewLeaseResponse, err error) { if containerName == "" { - return resp, fmt.Errorf("`containerName` cannot be an empty string") + err = fmt.Errorf("`containerName` cannot be an empty string") + return } if strings.ToLower(containerName) != containerName { - return resp, fmt.Errorf("`containerName` must be a lower-cased string") + err = fmt.Errorf("`containerName` must be a lower-cased string") + return } if blobName == "" { - return resp, fmt.Errorf("`blobName` cannot be an empty string") + err = fmt.Errorf("`blobName` cannot be an empty string") + return } if input.LeaseID == "" { - return resp, fmt.Errorf("`input.LeaseID` cannot be an empty string") + err = fmt.Errorf("`input.LeaseID` cannot be an empty string") + return } opts := client.RequestOptions{ @@ -53,7 +56,11 @@ func (c Client) RenewLease(ctx context.Context, containerName, blobName string, return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/metadata_set.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/metadata_set.go index 604e7a7bd31d..ce6c047d0256 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/metadata_set.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/metadata_set.go @@ -21,26 +21,29 @@ type SetMetaDataInput struct { } type SetMetaDataResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } // SetMetaData marks the specified blob or snapshot for deletion. The blob is later deleted during garbage collection. -func (c Client) SetMetaData(ctx context.Context, containerName, blobName string, input SetMetaDataInput) (resp SetMetaDataResponse, err error) { - +func (c Client) SetMetaData(ctx context.Context, containerName, blobName string, input SetMetaDataInput) (result SetMetaDataResponse, err error) { if containerName == "" { - return resp, fmt.Errorf("`containerName` cannot be an empty string") + err = fmt.Errorf("`containerName` cannot be an empty string") + return } if strings.ToLower(containerName) != containerName { - return resp, fmt.Errorf("`containerName` must be a lower-cased string") + err = fmt.Errorf("`containerName` must be a lower-cased string") + return } if blobName == "" { - return resp, fmt.Errorf("`blobName` cannot be an empty string") + err = fmt.Errorf("`blobName` cannot be an empty string") + return } - if err := metadata.Validate(input.MetaData); err != nil { - return resp, fmt.Errorf(fmt.Sprintf("`input.MetaData` is not valid: %s.", err)) + if err = metadata.Validate(input.MetaData); err != nil { + err = fmt.Errorf(fmt.Sprintf("`input.MetaData` is not valid: %s.", err)) + return } opts := client.RequestOptions{ @@ -60,7 +63,11 @@ func (c Client) SetMetaData(ctx context.Context, containerName, blobName string, return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/properties_get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/properties_get.go index 86b7c1100bd5..bc89f13a877d 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/properties_get.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/properties_get.go @@ -3,13 +3,13 @@ package blobs import ( "context" "fmt" + "github.com/tombuildsstuff/giovanni/storage/internal/metadata" "net/http" "strconv" "strings" "github.com/hashicorp/go-azure-sdk/sdk/client" "github.com/hashicorp/go-azure-sdk/sdk/odata" - "github.com/tombuildsstuff/giovanni/storage/internal/metadata" ) type GetPropertiesInput struct { @@ -19,7 +19,7 @@ type GetPropertiesInput struct { } type GetPropertiesResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response // The tier of page blob on a premium storage account or tier of block blob on blob storage or general purpose v2 account. AccessTier AccessTier @@ -161,16 +161,18 @@ type GetPropertiesResponse struct { } // GetProperties returns all user-defined metadata, standard HTTP properties, and system properties for the blob -func (c Client) GetProperties(ctx context.Context, containerName, blobName string, input GetPropertiesInput) (resp GetPropertiesResponse, err error) { - +func (c Client) GetProperties(ctx context.Context, containerName, blobName string, input GetPropertiesInput) (result GetPropertiesResponse, err error) { if containerName == "" { - return resp, fmt.Errorf("`containerName` cannot be an empty string") + err = fmt.Errorf("`containerName` cannot be an empty string") + return } if strings.ToLower(containerName) != containerName { - return resp, fmt.Errorf("`containerName` must be a lower-cased string") + err = fmt.Errorf("`containerName` must be a lower-cased string") + return } if blobName == "" { - return resp, fmt.Errorf("`blobName` cannot be an empty string") + err = fmt.Errorf("`blobName` cannot be an empty string") + return } opts := client.RequestOptions{ @@ -190,77 +192,79 @@ func (c Client) GetProperties(ctx context.Context, containerName, blobName strin return } - resp.HttpResponse, err = req.Execute(ctx) - if err != nil { - err = fmt.Errorf("executing request: %+v", err) - return - } - - if resp.HttpResponse != nil { - if resp.HttpResponse.Header != nil { - resp.AccessTier = AccessTier(resp.HttpResponse.Header.Get("x-ms-access-tier")) - resp.AccessTierChangeTime = resp.HttpResponse.Header.Get("x-ms-access-tier-change-time") - resp.ArchiveStatus = ArchiveStatus(resp.HttpResponse.Header.Get("x-ms-archive-status")) - resp.BlobCommittedBlockCount = resp.HttpResponse.Header.Get("x-ms-blob-committed-block-count") - resp.BlobSequenceNumber = resp.HttpResponse.Header.Get("x-ms-blob-sequence-number") - resp.BlobType = BlobType(resp.HttpResponse.Header.Get("x-ms-blob-type")) - resp.CacheControl = resp.HttpResponse.Header.Get("Cache-Control") - resp.ContentDisposition = resp.HttpResponse.Header.Get("Content-Disposition") - resp.ContentEncoding = resp.HttpResponse.Header.Get("Content-Encoding") - resp.ContentLanguage = resp.HttpResponse.Header.Get("Content-Language") - resp.ContentMD5 = resp.HttpResponse.Header.Get("Content-MD5") - resp.ContentType = resp.HttpResponse.Header.Get("Content-Type") - resp.CopyCompletionTime = resp.HttpResponse.Header.Get("x-ms-copy-completion-time") - resp.CopyDestinationSnapshot = resp.HttpResponse.Header.Get("x-ms-copy-destination-snapshot") - resp.CopyID = resp.HttpResponse.Header.Get("x-ms-copy-id") - resp.CopyProgress = resp.HttpResponse.Header.Get("x-ms-copy-progress") - resp.CopySource = resp.HttpResponse.Header.Get("x-ms-copy-source") - resp.CopyStatus = CopyStatus(resp.HttpResponse.Header.Get("x-ms-copy-status")) - resp.CopyStatusDescription = resp.HttpResponse.Header.Get("x-ms-copy-status-description") - resp.CreationTime = resp.HttpResponse.Header.Get("x-ms-creation-time") - resp.ETag = resp.HttpResponse.Header.Get("Etag") - resp.LastModified = resp.HttpResponse.Header.Get("Last-Modified") - resp.LeaseDuration = LeaseDuration(resp.HttpResponse.Header.Get("x-ms-lease-duration")) - resp.LeaseState = LeaseState(resp.HttpResponse.Header.Get("x-ms-lease-state")) - resp.LeaseStatus = LeaseStatus(resp.HttpResponse.Header.Get("x-ms-lease-status")) - resp.MetaData = metadata.ParseFromHeaders(resp.HttpResponse.Header) - - if v := resp.HttpResponse.Header.Get("x-ms-access-tier-inferred"); v != "" { + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + 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")) + result.BlobCommittedBlockCount = resp.Header.Get("x-ms-blob-committed-block-count") + result.BlobSequenceNumber = resp.Header.Get("x-ms-blob-sequence-number") + result.BlobType = BlobType(resp.Header.Get("x-ms-blob-type")) + result.CacheControl = resp.Header.Get("Cache-Control") + result.ContentDisposition = resp.Header.Get("Content-Disposition") + result.ContentEncoding = resp.Header.Get("Content-Encoding") + result.ContentLanguage = resp.Header.Get("Content-Language") + result.ContentMD5 = resp.Header.Get("Content-MD5") + result.ContentType = resp.Header.Get("Content-Type") + result.CopyCompletionTime = resp.Header.Get("x-ms-copy-completion-time") + result.CopyDestinationSnapshot = resp.Header.Get("x-ms-copy-destination-snapshot") + result.CopyID = resp.Header.Get("x-ms-copy-id") + result.CopyProgress = resp.Header.Get("x-ms-copy-progress") + result.CopySource = resp.Header.Get("x-ms-copy-source") + result.CopyStatus = CopyStatus(resp.Header.Get("x-ms-copy-status")) + result.CopyStatusDescription = resp.Header.Get("x-ms-copy-status-description") + result.CreationTime = resp.Header.Get("x-ms-creation-time") + result.ETag = resp.Header.Get("Etag") + result.LastModified = resp.Header.Get("Last-Modified") + result.LeaseDuration = LeaseDuration(resp.Header.Get("x-ms-lease-duration")) + result.LeaseState = LeaseState(resp.Header.Get("x-ms-lease-state")) + result.LeaseStatus = LeaseStatus(resp.Header.Get("x-ms-lease-status")) + result.MetaData = metadata.ParseFromHeaders(resp.Header) + + if v := resp.Header.Get("x-ms-access-tier-inferred"); v != "" { b, innerErr := strconv.ParseBool(v) if innerErr != nil { err = fmt.Errorf("error parsing %q as a bool: %s", v, innerErr) return } - resp.AccessTierInferred = b + result.AccessTierInferred = b } - if v := resp.HttpResponse.Header.Get("Content-Length"); v != "" { + if v := resp.Header.Get("Content-Length"); v != "" { i, innerErr := strconv.Atoi(v) if innerErr != nil { err = fmt.Errorf("error parsing %q as an integer: %s", v, innerErr) } - resp.ContentLength = int64(i) + result.ContentLength = int64(i) } - if v := resp.HttpResponse.Header.Get("x-ms-incremental-copy"); v != "" { + if v := resp.Header.Get("x-ms-incremental-copy"); v != "" { b, innerErr := strconv.ParseBool(v) if innerErr != nil { err = fmt.Errorf("error parsing %q as a bool: %s", v, innerErr) return } - resp.IncrementalCopy = b + result.IncrementalCopy = b } - if v := resp.HttpResponse.Header.Get("x-ms-server-encrypted"); v != "" { + if v := resp.Header.Get("x-ms-server-encrypted"); v != "" { b, innerErr := strconv.ParseBool(v) if innerErr != nil { err = fmt.Errorf("error parsing %q as a bool: %s", v, innerErr) return } - resp.ServerEncrypted = b + result.ServerEncrypted = b } } } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } return } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/properties_set.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/properties_set.go index ebe098556ded..73b417f04540 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/properties_set.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/properties_set.go @@ -25,25 +25,24 @@ type SetPropertiesInput struct { } type SetPropertiesResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response BlobSequenceNumber string Etag string } // SetProperties sets system properties on the blob. -func (c Client) SetProperties(ctx context.Context, containerName, blobName string, input SetPropertiesInput) (resp SetPropertiesResponse, err error) { - +func (c Client) SetProperties(ctx context.Context, containerName, blobName string, input SetPropertiesInput) (result SetPropertiesResponse, err error) { if containerName == "" { - return resp, fmt.Errorf("`containerName` cannot be an empty string") + return result, fmt.Errorf("`containerName` cannot be an empty string") } if strings.ToLower(containerName) != containerName { - return resp, fmt.Errorf("`containerName` must be a lower-cased string") + return result, fmt.Errorf("`containerName` must be a lower-cased string") } if blobName == "" { - return resp, fmt.Errorf("`blobName` cannot be an empty string") + return result, fmt.Errorf("`blobName` cannot be an empty string") } opts := client.RequestOptions{ @@ -63,7 +62,11 @@ func (c Client) SetProperties(ctx context.Context, containerName, blobName strin return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_append_blob.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_append_blob.go index 0f3aa30733a5..9217bf4eca0a 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_append_blob.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_append_blob.go @@ -23,27 +23,30 @@ type PutAppendBlobInput struct { } type PutAppendBlobResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } // PutAppendBlob is a wrapper around the Put API call (with a stricter input object) // which creates a new append blob, or updates the content of an existing blob. -func (c Client) PutAppendBlob(ctx context.Context, containerName, blobName string, input PutAppendBlobInput) (resp PutAppendBlobResponse, err error) { - +func (c Client) PutAppendBlob(ctx context.Context, containerName, blobName string, input PutAppendBlobInput) (result PutAppendBlobResponse, err error) { if containerName == "" { - return resp, fmt.Errorf("`containerName` cannot be an empty string") + err = fmt.Errorf("`containerName` cannot be an empty string") + return } if strings.ToLower(containerName) != containerName { - return resp, fmt.Errorf("`containerName` must be a lower-cased string") + err = fmt.Errorf("`containerName` must be a lower-cased string") + return } if blobName == "" { - return resp, fmt.Errorf("`blobName` cannot be an empty string") + err = fmt.Errorf("`blobName` cannot be an empty string") + return } - if err := metadata.Validate(input.MetaData); err != nil { - return resp, fmt.Errorf(fmt.Sprintf("`input.MetaData` is not valid: %s.", err)) + if err = metadata.Validate(input.MetaData); err != nil { + err = fmt.Errorf(fmt.Sprintf("`input.MetaData` is not valid: %s.", err)) + return } opts := client.RequestOptions{ @@ -63,7 +66,11 @@ func (c Client) PutAppendBlob(ctx context.Context, containerName, blobName strin return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_block.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_block.go index a6059c4aed27..32b672211155 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_block.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_block.go @@ -19,32 +19,36 @@ type PutBlockInput struct { } type PutBlockResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response ContentMD5 string } // PutBlock creates a new block to be committed as part of a blob. -func (c Client) PutBlock(ctx context.Context, containerName, blobName string, input PutBlockInput) (resp PutBlockResponse, err error) { - +func (c Client) PutBlock(ctx context.Context, containerName, blobName string, input PutBlockInput) (result PutBlockResponse, err error) { if containerName == "" { - return resp, fmt.Errorf("`containerName` cannot be an empty string") + err = fmt.Errorf("`containerName` cannot be an empty string") + return } if strings.ToLower(containerName) != containerName { - return resp, fmt.Errorf("`containerName` must be a lower-cased string") + err = fmt.Errorf("`containerName` must be a lower-cased string") + return } if blobName == "" { - return resp, fmt.Errorf("`blobName` cannot be an empty string") + err = fmt.Errorf("`blobName` cannot be an empty string") + return } if input.BlockID == "" { - return resp, fmt.Errorf("`input.BlockID` cannot be an empty string") + err = fmt.Errorf("`input.BlockID` cannot be an empty string") + return } if len(input.Content) == 0 { - return resp, fmt.Errorf("`input.Content` cannot be empty") + err = fmt.Errorf("`input.Content` cannot be empty") + return } opts := client.RequestOptions{ @@ -66,10 +70,15 @@ func (c Client) PutBlock(ctx context.Context, containerName, blobName string, in err = req.Marshal(&input.Content) if err != nil { - return resp, fmt.Errorf("marshalling request: %v", err) + err = fmt.Errorf("marshalling request: %+v", err) + return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_block_blob.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_block_blob.go index 462ea17272a0..31ffb25ec12e 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_block_blob.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_block_blob.go @@ -25,31 +25,35 @@ type PutBlockBlobInput struct { } type PutBlockBlobResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } // PutBlockBlob is a wrapper around the Put API call (with a stricter input object) // which creates a new block append blob, or updates the content of an existing block blob. -func (c Client) PutBlockBlob(ctx context.Context, containerName, blobName string, input PutBlockBlobInput) (resp PutBlockBlobResponse, err error) { - +func (c Client) PutBlockBlob(ctx context.Context, containerName, blobName string, input PutBlockBlobInput) (result PutBlockBlobResponse, err error) { if containerName == "" { - return resp, fmt.Errorf("`containerName` cannot be an empty string") + err = fmt.Errorf("`containerName` cannot be an empty string") + return } if strings.ToLower(containerName) != containerName { - return resp, fmt.Errorf("`containerName` must be a lower-cased string") + err = fmt.Errorf("`containerName` must be a lower-cased string") + return } if blobName == "" { - return resp, fmt.Errorf("`blobName` cannot be an empty string") + err = fmt.Errorf("`blobName` cannot be an empty string") + return } if input.Content != nil && len(*input.Content) == 0 { - return resp, fmt.Errorf("`input.Content` must either be nil or not empty") + err = fmt.Errorf("`input.Content` must either be nil or not empty") + return } - if err := metadata.Validate(input.MetaData); err != nil { - return resp, fmt.Errorf(fmt.Sprintf("`input.MetaData` is not valid: %s.", err)) + if err = metadata.Validate(input.MetaData); err != nil { + err = fmt.Errorf(fmt.Sprintf("`input.MetaData` is not valid: %s.", err)) + return } opts := client.RequestOptions{ @@ -71,10 +75,15 @@ func (c Client) PutBlockBlob(ctx context.Context, containerName, blobName string err = req.Marshal(&input.Content) if err != nil { - return resp, fmt.Errorf("marshalling request: %v", err) + err = fmt.Errorf("marshalling request: %+v", err) + return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_block_blob_file.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_block_blob_file.go index 932fb320607d..f5f21b0736ed 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_block_blob_file.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_block_blob_file.go @@ -11,7 +11,7 @@ import ( func (c Client) PutBlockBlobFromFile(ctx context.Context, containerName, blobName string, file *os.File, input PutBlockBlobInput) error { fileInfo, err := file.Stat() if err != nil { - return fmt.Errorf("error loading file info: %s", err) + return fmt.Errorf("loading file info: %s", err) } fileSize := fileInfo.Size() @@ -20,14 +20,14 @@ func (c Client) PutBlockBlobFromFile(ctx context.Context, containerName, blobNam _, err = file.ReadAt(bytes, 0) if err != nil { if err != io.EOF { - return fmt.Errorf("Error reading bytes: %s", err) + return fmt.Errorf("reading bytes: %s", err) } } input.Content = &bytes if _, err = c.PutBlockBlob(ctx, containerName, blobName, input); err != nil { - return fmt.Errorf("error putting bytes: %s", err) + return fmt.Errorf("putting bytes: %s", err) } return nil diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_block_list.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_block_list.go index bfe451b941c9..142136de2eba 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_block_list.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_block_list.go @@ -34,7 +34,7 @@ type PutBlockListInput struct { } type PutBlockListResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response ContentMD5 string ETag string @@ -44,18 +44,20 @@ type PutBlockListResponse struct { // PutBlockList writes a blob by specifying the list of block IDs that make up the blob. // In order to be written as part of a blob, a block must have been successfully written // to the server in a prior Put Block operation. -func (c Client) PutBlockList(ctx context.Context, containerName, blobName string, input PutBlockListInput) (resp PutBlockListResponse, err error) { - +func (c Client) PutBlockList(ctx context.Context, containerName, blobName string, input PutBlockListInput) (result PutBlockListResponse, err error) { if containerName == "" { - return resp, fmt.Errorf("`containerName` cannot be an empty string") + err = fmt.Errorf("`containerName` cannot be an empty string") + return } if strings.ToLower(containerName) != containerName { - return resp, fmt.Errorf("`containerName` must be a lower-cased string") + err = fmt.Errorf("`containerName` must be a lower-cased string") + return } if blobName == "" { - return resp, fmt.Errorf("`blobName` cannot be an empty string") + err = fmt.Errorf("`blobName` cannot be an empty string") + return } opts := client.RequestOptions{ @@ -77,23 +79,26 @@ func (c Client) PutBlockList(ctx context.Context, containerName, blobName string err = req.Marshal(&input.BlockList) if err != nil { - return resp, fmt.Errorf("marshalling request: %v", err) + err = fmt.Errorf("marshalling request: %+v", err) + return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if resp.Header != nil { + result.ContentMD5 = resp.Header.Get("Content-MD5") + result.ETag = resp.Header.Get("ETag") + result.LastModified = resp.Header.Get("Last-Modified") + } + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return } - if resp.HttpResponse != nil { - if resp.HttpResponse.Header != nil { - resp.ContentMD5 = resp.HttpResponse.Header.Get("Content-MD5") - resp.ETag = resp.HttpResponse.Header.Get("ETag") - resp.LastModified = resp.HttpResponse.Header.Get("Last-Modified") - } - } - return } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_block_url.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_block_url.go index cd8487c5c265..3cac42709489 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_block_url.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_block_url.go @@ -20,31 +20,35 @@ type PutBlockFromURLInput struct { } type PutBlockFromURLResponse struct { - HttpResponse *client.Response ContentMD5 string + HttpResponse *http.Response } // PutBlockFromURL creates a new block to be committed as part of a blob where the contents are read from a URL -func (c Client) PutBlockFromURL(ctx context.Context, containerName, blobName string, input PutBlockFromURLInput) (resp PutBlockFromURLResponse, err error) { - +func (c Client) PutBlockFromURL(ctx context.Context, containerName, blobName string, input PutBlockFromURLInput) (result PutBlockFromURLResponse, err error) { if containerName == "" { - return resp, fmt.Errorf("`containerName` cannot be an empty string") + err = fmt.Errorf("`containerName` cannot be an empty string") + return } if strings.ToLower(containerName) != containerName { - return resp, fmt.Errorf("`containerName` must be a lower-cased string") + err = fmt.Errorf("`containerName` must be a lower-cased string") + return } if blobName == "" { - return resp, fmt.Errorf("`blobName` cannot be an empty string") + err = fmt.Errorf("`blobName` cannot be an empty string") + return } if input.BlockID == "" { - return resp, fmt.Errorf("`input.BlockID` cannot be an empty string") + err = fmt.Errorf("`input.BlockID` cannot be an empty string") + return } if input.CopySource == "" { - return resp, fmt.Errorf("`input.CopySource` cannot be an empty string") + err = fmt.Errorf("`input.CopySource` cannot be an empty string") + return } opts := client.RequestOptions{ @@ -64,18 +68,20 @@ func (c Client) PutBlockFromURL(ctx context.Context, containerName, blobName str return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if resp.Header != nil { + result.ContentMD5 = resp.Header.Get("Content-MD5") + } + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return } - if resp.HttpResponse != nil { - if resp.HttpResponse.Header != nil { - resp.ContentMD5 = resp.HttpResponse.Header.Get("Content-MD5") - } - } - return } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_page_blob.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_page_blob.go index 2b733c4c1311..281d20e914fc 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_page_blob.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_page_blob.go @@ -28,27 +28,30 @@ type PutPageBlobInput struct { } type PutPageBlobResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } // PutPageBlob is a wrapper around the Put API call (with a stricter input object) // which creates a new block blob, or updates the content of an existing page blob. -func (c Client) PutPageBlob(ctx context.Context, containerName, blobName string, input PutPageBlobInput) (resp PutPageBlobResponse, err error) { - +func (c Client) PutPageBlob(ctx context.Context, containerName, blobName string, input PutPageBlobInput) (result PutPageBlobResponse, err error) { if containerName == "" { - return resp, fmt.Errorf("`containerName` cannot be an empty string") + err = fmt.Errorf("`containerName` cannot be an empty string") + return } if strings.ToLower(containerName) != containerName { - return resp, fmt.Errorf("`containerName` must be a lower-cased string") + err = fmt.Errorf("`containerName` must be a lower-cased string") + return } if blobName == "" { - return resp, fmt.Errorf("`blobName` cannot be an empty string") + err = fmt.Errorf("`blobName` cannot be an empty string") + return } if input.BlobContentLengthBytes == 0 || input.BlobContentLengthBytes%512 != 0 { - return resp, fmt.Errorf("`input.BlobContentLengthBytes` must be aligned to a 512-byte boundary") + err = fmt.Errorf("`input.BlobContentLengthBytes` must be aligned to a 512-byte boundary") + return } opts := client.RequestOptions{ @@ -68,7 +71,11 @@ func (c Client) PutPageBlob(ctx context.Context, containerName, blobName string, return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_page_clear.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_page_clear.go index 1a995138d166..9b8ad4f84c60 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_page_clear.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_page_clear.go @@ -18,30 +18,34 @@ type PutPageClearInput struct { } type PutPageClearResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } // PutPageClear clears a range of pages within a page blob. -func (c Client) PutPageClear(ctx context.Context, containerName, blobName string, input PutPageClearInput) (resp PutPageClearResponse, err error) { - +func (c Client) PutPageClear(ctx context.Context, containerName, blobName string, input PutPageClearInput) (result PutPageClearResponse, err error) { if containerName == "" { - return resp, fmt.Errorf("`containerName` cannot be an empty string") + err = fmt.Errorf("`containerName` cannot be an empty string") + return } if strings.ToLower(containerName) != containerName { - return resp, fmt.Errorf("`containerName` must be a lower-cased string") + err = fmt.Errorf("`containerName` must be a lower-cased string") + return } if blobName == "" { - return resp, fmt.Errorf("`blobName` cannot be an empty string") + err = fmt.Errorf("`blobName` cannot be an empty string") + return } if input.StartByte < 0 { - return resp, fmt.Errorf("`input.StartByte` must be greater than or equal to 0") + err = fmt.Errorf("`input.StartByte` must be greater than or equal to 0") + return } if input.EndByte <= 0 { - return resp, fmt.Errorf("`input.EndByte` must be greater than 0") + err = fmt.Errorf("`input.EndByte` must be greater than 0") + return } opts := client.RequestOptions{ @@ -61,7 +65,11 @@ func (c Client) PutPageClear(ctx context.Context, containerName, blobName string return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_page_update.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_page_update.go index 448fe343d903..187ffbb6161d 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_page_update.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_page_update.go @@ -1,10 +1,8 @@ package blobs import ( - "bytes" "context" "fmt" - "io" "net/http" "strconv" "strings" @@ -29,7 +27,7 @@ type PutPageUpdateInput struct { } type PutPageUpdateResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response BlobSequenceNumber string ContentMD5 string @@ -37,32 +35,37 @@ type PutPageUpdateResponse struct { } // PutPageUpdate writes a range of pages to a page blob. -func (c Client) PutPageUpdate(ctx context.Context, containerName, blobName string, input PutPageUpdateInput) (resp PutPageUpdateResponse, err error) { - +func (c Client) PutPageUpdate(ctx context.Context, containerName, blobName string, input PutPageUpdateInput) (result PutPageUpdateResponse, err error) { if containerName == "" { - return resp, fmt.Errorf("`containerName` cannot be an empty string") + err = fmt.Errorf("`containerName` cannot be an empty string") + return } if strings.ToLower(containerName) != containerName { - return resp, fmt.Errorf("`containerName` must be a lower-cased string") + err = fmt.Errorf("`containerName` must be a lower-cased string") + return } if blobName == "" { - return resp, fmt.Errorf("`blobName` cannot be an empty string") + err = fmt.Errorf("`blobName` cannot be an empty string") + return } if input.StartByte < 0 { - return resp, fmt.Errorf("`input.StartByte` must be greater than or equal to 0") + err = fmt.Errorf("`input.StartByte` must be greater than or equal to 0") + return } if input.EndByte <= 0 { - return resp, fmt.Errorf("`input.EndByte` must be greater than 0") + err = fmt.Errorf("`input.EndByte` must be greater than 0") + return } expectedSize := (input.EndByte - input.StartByte) + 1 actualSize := int64(len(input.Content)) if expectedSize != actualSize { - return resp, fmt.Errorf(fmt.Sprintf("Content Size was defined as %d but got %d.", expectedSize, actualSize)) + err = fmt.Errorf(fmt.Sprintf("Content Size was defined as %d but got %d.", expectedSize, actualSize)) + return } opts := client.RequestOptions{ @@ -82,21 +85,26 @@ func (c Client) PutPageUpdate(ctx context.Context, containerName, blobName strin return } - req.Body = io.NopCloser(bytes.NewReader(input.Content)) - req.ContentLength = int64(len(input.Content)) + // TODO commenting these out to see if they're really needed (net/http should do this) (@manicminer) + //req.Body = io.NopCloser(bytes.NewReader(input.Content)) + //req.ContentLength = int64(len(input.Content)) + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response - resp.HttpResponse, err = req.Execute(ctx) + 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") + } + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return } - if resp.HttpResponse != nil && resp.HttpResponse.Header != nil { - resp.BlobSequenceNumber = resp.HttpResponse.Header.Get("x-ms-blob-sequence-number") - resp.ContentMD5 = resp.HttpResponse.Header.Get("Content-MD5") - resp.LastModified = resp.HttpResponse.Header.Get("Last-Modified") - } - return } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/set_tier.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/set_tier.go index 35cca5b8d7f9..66b9d64884ae 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/set_tier.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/set_tier.go @@ -15,22 +15,24 @@ type SetTierInput struct { } type SetTierResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } // SetTier sets the tier on a blob. -func (c Client) SetTier(ctx context.Context, containerName, blobName string, input SetTierInput) (resp SetTierResponse, err error) { - +func (c Client) SetTier(ctx context.Context, containerName, blobName string, input SetTierInput) (result SetTierResponse, err error) { if containerName == "" { - return resp, fmt.Errorf("`containerName` cannot be an empty string") + err = fmt.Errorf("`containerName` cannot be an empty string") + return } if strings.ToLower(containerName) != containerName { - return resp, fmt.Errorf("`containerName` must be a lower-cased string") + err = fmt.Errorf("`containerName` must be a lower-cased string") + return } if blobName == "" { - return resp, fmt.Errorf("`blobName` cannot be an empty string") + err = fmt.Errorf("`blobName` cannot be an empty string") + return } opts := client.RequestOptions{ @@ -51,7 +53,11 @@ func (c Client) SetTier(ctx context.Context, containerName, blobName string, inp return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/snapshot.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/snapshot.go index 8a90dcdaf204..0a8f8caa1ae4 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/snapshot.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/snapshot.go @@ -41,7 +41,7 @@ type SnapshotInput struct { } type SnapshotResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response // The ETag of the snapshot ETag string @@ -53,22 +53,25 @@ type SnapshotResponse struct { } // Snapshot captures a Snapshot of a given Blob -func (c Client) Snapshot(ctx context.Context, containerName, blobName string, input SnapshotInput) (resp SnapshotResponse, err error) { - +func (c Client) Snapshot(ctx context.Context, containerName, blobName string, input SnapshotInput) (result SnapshotResponse, err error) { if containerName == "" { - return resp, fmt.Errorf("`containerName` cannot be an empty string") + err = fmt.Errorf("`containerName` cannot be an empty string") + return } if strings.ToLower(containerName) != containerName { - return resp, fmt.Errorf("`containerName` must be a lower-cased string") + err = fmt.Errorf("`containerName` must be a lower-cased string") + return } if blobName == "" { - return resp, fmt.Errorf("`blobName` cannot be an empty string") + err = fmt.Errorf("`blobName` cannot be an empty string") + return } - if err := metadata.Validate(input.MetaData); err != nil { - return resp, fmt.Errorf(fmt.Sprintf("`input.MetaData` is not valid: %s.", err)) + if err = metadata.Validate(input.MetaData); err != nil { + err = fmt.Errorf(fmt.Sprintf("`input.MetaData` is not valid: %s.", err)) + return } opts := client.RequestOptions{ @@ -88,17 +91,21 @@ func (c Client) Snapshot(ctx context.Context, containerName, blobName string, in return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if resp.Header != nil { + result.ETag = resp.Header.Get("ETag") + result.SnapshotDateTime = resp.Header.Get("x-ms-snapshot") + } + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return } - if resp.HttpResponse != nil && resp.HttpResponse.Header != nil { - resp.ETag = resp.HttpResponse.Header.Get("ETag") - resp.SnapshotDateTime = resp.HttpResponse.Header.Get("x-ms-snapshot") - } - return } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/snapshot_get_properties.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/snapshot_get_properties.go index 57a02f34e819..26ddfa8cb4a9 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/snapshot_get_properties.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/snapshot_get_properties.go @@ -3,13 +3,13 @@ package blobs import ( "context" "fmt" + "github.com/tombuildsstuff/giovanni/storage/internal/metadata" "net/http" "strconv" "strings" "github.com/hashicorp/go-azure-sdk/sdk/client" "github.com/hashicorp/go-azure-sdk/sdk/odata" - "github.com/tombuildsstuff/giovanni/storage/internal/metadata" ) type GetSnapshotPropertiesInput struct { @@ -23,22 +23,25 @@ type GetSnapshotPropertiesInput struct { // GetSnapshotProperties returns all user-defined metadata, standard HTTP properties, and system properties for // the specified snapshot of a blob -func (c Client) GetSnapshotProperties(ctx context.Context, containerName, blobName string, input GetSnapshotPropertiesInput) (resp GetPropertiesResponse, err error) { - +func (c Client) GetSnapshotProperties(ctx context.Context, containerName, blobName string, input GetSnapshotPropertiesInput) (result GetPropertiesResponse, err error) { if containerName == "" { - return resp, fmt.Errorf("`containerName` cannot be an empty string") + err = fmt.Errorf("`containerName` cannot be an empty string") + return } if strings.ToLower(containerName) != containerName { - return resp, fmt.Errorf("`containerName` must be a lower-cased string") + err = fmt.Errorf("`containerName` must be a lower-cased string") + return } if blobName == "" { - return resp, fmt.Errorf("`blobName` cannot be an empty string") + err = fmt.Errorf("`blobName` cannot be an empty string") + return } if input.SnapshotID == "" { - return resp, fmt.Errorf("`input.SnapshotID` cannot be an empty string") + err = fmt.Errorf("`input.SnapshotID` cannot be an empty string") + return } opts := client.RequestOptions{ @@ -58,81 +61,86 @@ func (c Client) GetSnapshotProperties(ctx context.Context, containerName, blobNa return } - resp.HttpResponse, err = req.Execute(ctx) - if err != nil { - err = fmt.Errorf("executing request: %+v", err) - return - } - - if resp.HttpResponse != nil { - if resp.HttpResponse.Header != nil { - resp.AccessTier = AccessTier(resp.HttpResponse.Header.Get("x-ms-access-tier")) - resp.AccessTierChangeTime = resp.HttpResponse.Header.Get("x-ms-access-tier-change-time") - resp.ArchiveStatus = ArchiveStatus(resp.HttpResponse.Header.Get("x-ms-archive-status")) - resp.BlobCommittedBlockCount = resp.HttpResponse.Header.Get("x-ms-blob-committed-block-count") - resp.BlobSequenceNumber = resp.HttpResponse.Header.Get("x-ms-blob-sequence-number") - resp.BlobType = BlobType(resp.HttpResponse.Header.Get("x-ms-blob-type")) - resp.CacheControl = resp.HttpResponse.Header.Get("Cache-Control") - resp.ContentDisposition = resp.HttpResponse.Header.Get("Content-Disposition") - resp.ContentEncoding = resp.HttpResponse.Header.Get("Content-Encoding") - resp.ContentLanguage = resp.HttpResponse.Header.Get("Content-Language") - resp.ContentMD5 = resp.HttpResponse.Header.Get("Content-MD5") - resp.ContentType = resp.HttpResponse.Header.Get("Content-Type") - resp.CopyCompletionTime = resp.HttpResponse.Header.Get("x-ms-copy-completion-time") - resp.CopyDestinationSnapshot = resp.HttpResponse.Header.Get("x-ms-copy-destination-snapshot") - resp.CopyID = resp.HttpResponse.Header.Get("x-ms-copy-id") - resp.CopyProgress = resp.HttpResponse.Header.Get("x-ms-copy-progress") - resp.CopySource = resp.HttpResponse.Header.Get("x-ms-copy-source") - resp.CopyStatus = CopyStatus(resp.HttpResponse.Header.Get("x-ms-copy-status")) - resp.CopyStatusDescription = resp.HttpResponse.Header.Get("x-ms-copy-status-description") - resp.CreationTime = resp.HttpResponse.Header.Get("x-ms-creation-time") - resp.ETag = resp.HttpResponse.Header.Get("Etag") - resp.LastModified = resp.HttpResponse.Header.Get("Last-Modified") - resp.LeaseDuration = LeaseDuration(resp.HttpResponse.Header.Get("x-ms-lease-duration")) - resp.LeaseState = LeaseState(resp.HttpResponse.Header.Get("x-ms-lease-state")) - resp.LeaseStatus = LeaseStatus(resp.HttpResponse.Header.Get("x-ms-lease-status")) - resp.MetaData = metadata.ParseFromHeaders(resp.HttpResponse.Header) - - if v := resp.HttpResponse.Header.Get("x-ms-access-tier-inferred"); v != "" { - b, innerErr := strconv.ParseBool(v) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + 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")) + result.BlobCommittedBlockCount = resp.Header.Get("x-ms-blob-committed-block-count") + result.BlobSequenceNumber = resp.Header.Get("x-ms-blob-sequence-number") + result.BlobType = BlobType(resp.Header.Get("x-ms-blob-type")) + result.CacheControl = resp.Header.Get("Cache-Control") + result.ContentDisposition = resp.Header.Get("Content-Disposition") + result.ContentEncoding = resp.Header.Get("Content-Encoding") + result.ContentLanguage = resp.Header.Get("Content-Language") + result.ContentMD5 = resp.Header.Get("Content-MD5") + result.ContentType = resp.Header.Get("Content-Type") + result.CopyCompletionTime = resp.Header.Get("x-ms-copy-completion-time") + result.CopyDestinationSnapshot = resp.Header.Get("x-ms-copy-destination-snapshot") + result.CopyID = resp.Header.Get("x-ms-copy-id") + result.CopyProgress = resp.Header.Get("x-ms-copy-progress") + result.CopySource = resp.Header.Get("x-ms-copy-source") + result.CopyStatus = CopyStatus(resp.Header.Get("x-ms-copy-status")) + result.CopyStatusDescription = resp.Header.Get("x-ms-copy-status-description") + result.CreationTime = resp.Header.Get("x-ms-creation-time") + result.ETag = resp.Header.Get("Etag") + result.LastModified = resp.Header.Get("Last-Modified") + result.LeaseDuration = LeaseDuration(resp.Header.Get("x-ms-lease-duration")) + result.LeaseState = LeaseState(resp.Header.Get("x-ms-lease-state")) + result.LeaseStatus = LeaseStatus(resp.Header.Get("x-ms-lease-status")) + result.MetaData = metadata.ParseFromHeaders(resp.Header) + + if v := resp.Header.Get("Content-Length"); v != "" { + i, innerErr := strconv.Atoi(v) if innerErr != nil { - err = fmt.Errorf("error parsing %q as a bool: %s", v, innerErr) - return + err = fmt.Errorf("parsing `Content-Length` header value %q: %+v", v, innerErr) } - resp.AccessTierInferred = b + result.ContentLength = int64(i) } - if v := resp.HttpResponse.Header.Get("Content-Length"); v != "" { - i, innerErr := strconv.Atoi(v) + if v := resp.Header.Get("x-ms-access-tier-inferred"); v != "" { + b, innerErr := strconv.ParseBool(v) if innerErr != nil { - err = fmt.Errorf("error parsing %q as an integer: %s", v, innerErr) + err = fmt.Errorf("parsing `x-ms-access-tier-inferred` header value %q: %+v", v, innerErr) + return } - resp.ContentLength = int64(i) + result.AccessTierInferred = b } - if v := resp.HttpResponse.Header.Get("x-ms-incremental-copy"); v != "" { + if v := resp.Header.Get("x-ms-incremental-copy"); v != "" { b, innerErr := strconv.ParseBool(v) if innerErr != nil { - err = fmt.Errorf("error parsing %q as a bool: %s", v, innerErr) + err = fmt.Errorf("parsing `x-ms-incremental-copy` header value %q: %+v", v, innerErr) return } - resp.IncrementalCopy = b + result.IncrementalCopy = b } - if v := resp.HttpResponse.Header.Get("x-ms-server-encrypted"); v != "" { + if v := resp.Header.Get("x-ms-server-encrypted"); v != "" { b, innerErr := strconv.ParseBool(v) if innerErr != nil { - err = fmt.Errorf("error parsing %q as a bool: %s", v, innerErr) + err = fmt.Errorf("parsing `\"x-ms-server-encrypted` header value %q: %+v", v, innerErr) return } - resp.ServerEncrypted = b + result.ServerEncrypted = b } } } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + if result.HttpResponse != nil { + } return } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/undelete.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/undelete.go index e46277c77af1..149971fc1035 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/undelete.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/undelete.go @@ -11,22 +11,24 @@ import ( ) type UndeleteResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } // Undelete restores the contents and metadata of soft deleted blob and any associated soft deleted snapshots. -func (c Client) Undelete(ctx context.Context, containerName, blobName string) (resp UndeleteResponse, err error) { - +func (c Client) Undelete(ctx context.Context, containerName, blobName string) (result UndeleteResponse, err error) { if containerName == "" { - return resp, fmt.Errorf("`containerName` cannot be an empty string") + err = fmt.Errorf("`containerName` cannot be an empty string") + return } if strings.ToLower(containerName) != containerName { - return resp, fmt.Errorf("`containerName` must be a lower-cased string") + err = fmt.Errorf("`containerName` must be a lower-cased string") + return } if blobName == "" { - return resp, fmt.Errorf("`blobName` cannot be an empty string") + err = fmt.Errorf("`blobName` cannot be an empty string") + return } opts := client.RequestOptions{ @@ -44,7 +46,11 @@ func (c Client) Undelete(ctx context.Context, containerName, blobName string) (r return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/create.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/create.go index 1acbae869d91..02bbce7f356f 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/create.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/create.go @@ -19,18 +19,20 @@ type CreateInput struct { } type CreateResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response Error *ErrorResponse `xml:"Error"` } // Create creates a new container under the specified account. // If the container with the same name already exists, the operation fails. -func (c Client) Create(ctx context.Context, containerName string, input CreateInput) (resp CreateResponse, err error) { +func (c Client) Create(ctx context.Context, containerName string, input CreateInput) (result CreateResponse, err error) { if containerName == "" { - return resp, fmt.Errorf("`containerName` cannot be an empty string") + err = fmt.Errorf("`containerName` cannot be an empty string") + return } - if err := metadata.Validate(input.MetaData); err != nil { - return resp, fmt.Errorf("`input.MetaData` is not valid: %+v", err) + if err = metadata.Validate(input.MetaData); err != nil { + err = fmt.Errorf("`input.MetaData` is not valid: %+v", err) + return } opts := client.RequestOptions{ @@ -45,12 +47,18 @@ func (c Client) Create(ctx context.Context, containerName string, input CreateIn }, Path: fmt.Sprintf("/%s", containerName), } + req, err := c.Client.NewRequest(ctx, opts) if err != nil { err = fmt.Errorf("building request: %+v", err) return } - resp.HttpResponse, err = req.Execute(ctx) + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/delete.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/delete.go index 0aea0ed7f1df..d654e4aba8a7 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/delete.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/delete.go @@ -9,14 +9,15 @@ import ( ) type DeleteResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } // Delete marks the specified container for deletion. // The container and any blobs contained within it are later deleted during garbage collection. -func (c Client) Delete(ctx context.Context, containerName string) (resp DeleteResponse, err error) { +func (c Client) Delete(ctx context.Context, containerName string) (result DeleteResponse, err error) { if containerName == "" { - return resp, fmt.Errorf("`containerName` cannot be an empty string") + err = fmt.Errorf("`containerName` cannot be an empty string") + return } opts := client.RequestOptions{ @@ -28,12 +29,18 @@ func (c Client) Delete(ctx context.Context, containerName string) (resp DeleteRe OptionsObject: containerOptions{}, Path: fmt.Sprintf("/%s", containerName), } + req, err := c.Client.NewRequest(ctx, opts) if err != nil { err = fmt.Errorf("building request: %+v", err) return } - resp.HttpResponse, err = req.Execute(ctx) + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/get_properties.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/get_properties.go index 2655b0ba89e1..44bf7a11a377 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/get_properties.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/get_properties.go @@ -16,14 +16,15 @@ type GetPropertiesInput struct { } type GetPropertiesResponse struct { - HttpResponse *client.Response - Model *ContainerProperties + ContainerProperties + HttpResponse *http.Response } // GetProperties returns the properties for this Container without a Lease -func (c Client) GetProperties(ctx context.Context, containerName string, input GetPropertiesInput) (resp GetPropertiesResponse, err error) { +func (c Client) GetProperties(ctx context.Context, containerName string, input GetPropertiesInput) (result GetPropertiesResponse, err error) { if containerName == "" { - return resp, fmt.Errorf("`containerName` cannot be an empty string") + err = fmt.Errorf("`containerName` cannot be an empty string") + return } opts := client.RequestOptions{ @@ -37,40 +38,45 @@ func (c Client) GetProperties(ctx context.Context, containerName string, input G }, Path: fmt.Sprintf("/%s", containerName), } + req, err := c.Client.NewRequest(ctx, opts) if err != nil { err = fmt.Errorf("building request: %+v", err) return } - resp.HttpResponse, err = req.Execute(ctx) + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if resp.Header != nil { + result.LeaseStatus = LeaseStatus(resp.Header.Get("x-ms-lease-status")) + result.LeaseState = LeaseState(resp.Header.Get("x-ms-lease-state")) + if result.LeaseStatus == Locked { + duration := LeaseDuration(resp.Header.Get("x-ms-lease-duration")) + result.LeaseDuration = &duration + } + + // If this header is not returned in the response, the container is private to the account owner. + accessLevel := resp.Header.Get("x-ms-blob-public-access") + if accessLevel != "" { + result.AccessLevel = AccessLevel(accessLevel) + } else { + result.AccessLevel = Private + } + + // we can't necessarily use strconv.ParseBool here since this could be nil (only in some API versions) + result.HasImmutabilityPolicy = strings.EqualFold(resp.Header.Get("x-ms-has-immutability-policy"), "true") + result.HasLegalHold = strings.EqualFold(resp.Header.Get("x-ms-has-legal-hold"), "true") + result.MetaData = metadata.ParseFromHeaders(resp.Header) + } + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return } - if resp.HttpResponse != nil { - resp.Model = &ContainerProperties{} - resp.Model.LeaseStatus = LeaseStatus(resp.HttpResponse.Header.Get("x-ms-lease-status")) - resp.Model.LeaseState = LeaseState(resp.HttpResponse.Header.Get("x-ms-lease-state")) - if resp.Model.LeaseStatus == Locked { - duration := LeaseDuration(resp.HttpResponse.Header.Get("x-ms-lease-duration")) - resp.Model.LeaseDuration = &duration - } - - // If this header is not returned in the response, the container is private to the account owner. - accessLevel := resp.HttpResponse.Header.Get("x-ms-blob-public-access") - if accessLevel != "" { - resp.Model.AccessLevel = AccessLevel(accessLevel) - } else { - resp.Model.AccessLevel = Private - } - - // we can't necessarily use strconv.ParseBool here since this could be nil (only in some API versions) - resp.Model.HasImmutabilityPolicy = strings.EqualFold(resp.HttpResponse.Header.Get("x-ms-has-immutability-policy"), "true") - resp.Model.HasLegalHold = strings.EqualFold(resp.HttpResponse.Header.Get("x-ms-has-legal-hold"), "true") - resp.Model.MetaData = metadata.ParseFromHeaders(resp.HttpResponse.Header) - } - return } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/lease_acquire.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/lease_acquire.go index 409f15a47172..a863c1498247 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/lease_acquire.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/lease_acquire.go @@ -18,8 +18,8 @@ type AcquireLeaseInput struct { } type AcquireLeaseResponse struct { - HttpResponse *client.Response - Model *AcquireLeaseModel + AcquireLeaseModel + HttpResponse *http.Response } type AcquireLeaseModel struct { @@ -27,13 +27,13 @@ type AcquireLeaseModel struct { } // AcquireLease establishes and manages a lock on a container for delete operations. -func (c Client) AcquireLease(ctx context.Context, containerName string, input AcquireLeaseInput) (resp AcquireLeaseResponse, err error) { +func (c Client) AcquireLease(ctx context.Context, containerName string, input AcquireLeaseInput) (result AcquireLeaseResponse, err error) { if containerName == "" { - return resp, fmt.Errorf("`containerName` cannot be an empty string") + return result, fmt.Errorf("`containerName` cannot be an empty string") } // An infinite lease duration is -1 seconds. A non-infinite lease can be between 15 and 60 seconds if input.LeaseDuration != -1 && (input.LeaseDuration <= 15 || input.LeaseDuration >= 60) { - return resp, fmt.Errorf("`input.LeaseDuration` must be -1 (infinite), or between 15 and 60 seconds") + return result, fmt.Errorf("`input.LeaseDuration` must be -1 (infinite), or between 15 and 60 seconds") } opts := client.RequestOptions{ @@ -48,23 +48,27 @@ func (c Client) AcquireLease(ctx context.Context, containerName string, input Ac }, Path: fmt.Sprintf("/%s", containerName), } + req, err := c.Client.NewRequest(ctx, opts) if err != nil { err = fmt.Errorf("building request: %+v", err) return } - resp.HttpResponse, err = req.Execute(ctx) + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if resp.Header != nil { + result.LeaseID = resp.Header.Get("x-ms-lease-id") + } + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return } - if resp.HttpResponse != nil { - resp.Model = &AcquireLeaseModel{ - LeaseID: resp.HttpResponse.Header.Get("x-ms-lease-id"), - } - } - return } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/lease_break.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/lease_break.go index 0ede9a818a0f..b141e2582f00 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/lease_break.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/lease_break.go @@ -3,11 +3,10 @@ package containers import ( "context" "fmt" - "net/http" - "strconv" - "github.com/hashicorp/go-azure-sdk/sdk/client" "github.com/hashicorp/go-azure-sdk/sdk/odata" + "net/http" + "strconv" ) type BreakLeaseInput struct { @@ -25,8 +24,8 @@ type BreakLeaseInput struct { } type BreakLeaseResponse struct { - HttpResponse *client.Response - Model *BreakLeaseModel + BreakLeaseModel + HttpResponse *http.Response } type BreakLeaseModel struct { @@ -36,12 +35,12 @@ type BreakLeaseModel struct { } // BreakLease breaks a lock based on it's Lease ID -func (c Client) BreakLease(ctx context.Context, containerName string, input BreakLeaseInput) (resp BreakLeaseResponse, err error) { +func (c Client) BreakLease(ctx context.Context, containerName string, input BreakLeaseInput) (result BreakLeaseResponse, err error) { if containerName == "" { - return resp, fmt.Errorf("`containerName` cannot be an empty string") + return result, fmt.Errorf("`containerName` cannot be an empty string") } if input.LeaseID == "" { - return resp, fmt.Errorf("`input.LeaseID` cannot be an empty string") + return result, fmt.Errorf("`input.LeaseID` cannot be an empty string") } opts := client.RequestOptions{ @@ -56,27 +55,30 @@ func (c Client) BreakLease(ctx context.Context, containerName string, input Brea }, Path: fmt.Sprintf("/%s", containerName), } + req, err := c.Client.NewRequest(ctx, opts) if err != nil { err = fmt.Errorf("building request: %+v", err) return } - resp.HttpResponse, err = req.Execute(ctx) - if err != nil { - err = fmt.Errorf("executing request: %+v", err) - return - } - if resp.HttpResponse != nil { - leaseRaw := resp.HttpResponse.Header.Get("x-ms-lease-time") - if leaseRaw != "" { - if i, err := strconv.Atoi(leaseRaw); err == nil { - resp.Model = &BreakLeaseModel{ - LeaseTime: i, + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + 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 } } } } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } return } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/lease_change.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/lease_change.go index 6326507707ee..1c1d7321066d 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/lease_change.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/lease_change.go @@ -15,8 +15,8 @@ type ChangeLeaseInput struct { } type ChangeLeaseResponse struct { - HttpResponse *client.Response - Model *ChangeLeaseModel + ChangeLeaseModel + HttpResponse *http.Response } type ChangeLeaseModel struct { @@ -24,15 +24,18 @@ type ChangeLeaseModel struct { } // ChangeLease changes the lock from one Lease ID to another Lease ID -func (c Client) ChangeLease(ctx context.Context, containerName string, input ChangeLeaseInput) (resp ChangeLeaseResponse, err error) { +func (c Client) ChangeLease(ctx context.Context, containerName string, input ChangeLeaseInput) (result ChangeLeaseResponse, err error) { if containerName == "" { - return resp, fmt.Errorf("`containerName` cannot be an empty string") + err = fmt.Errorf("`containerName` cannot be an empty string") + return } if input.ExistingLeaseID == "" { - return resp, fmt.Errorf("`input.ExistingLeaseID` cannot be an empty string") + err = fmt.Errorf("`input.ExistingLeaseID` cannot be an empty string") + return } if input.ProposedLeaseID == "" { - return resp, fmt.Errorf("`input.ProposedLeaseID` cannot be an empty string") + err = fmt.Errorf("`input.ProposedLeaseID` cannot be an empty string") + return } opts := client.RequestOptions{ @@ -47,23 +50,27 @@ func (c Client) ChangeLease(ctx context.Context, containerName string, input Cha }, Path: fmt.Sprintf("/%s", containerName), } + req, err := c.Client.NewRequest(ctx, opts) if err != nil { err = fmt.Errorf("building request: %+v", err) return } - resp.HttpResponse, err = req.Execute(ctx) + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if resp.Header != nil { + result.LeaseID = resp.Header.Get("x-ms-lease-id") + } + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return } - if resp.HttpResponse != nil { - resp.Model = &ChangeLeaseModel{ - LeaseID: resp.HttpResponse.Header.Get("x-ms-lease-id"), - } - } - return } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/lease_release.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/lease_release.go index 8a2cf4114e00..cdff4e2cf9ce 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/lease_release.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/lease_release.go @@ -14,16 +14,18 @@ type ReleaseLeaseInput struct { } type ReleaseLeaseResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } // ReleaseLease releases the lock based on the Lease ID -func (c Client) ReleaseLease(ctx context.Context, containerName string, input ReleaseLeaseInput) (resp ReleaseLeaseResponse, err error) { +func (c Client) ReleaseLease(ctx context.Context, containerName string, input ReleaseLeaseInput) (result ReleaseLeaseResponse, err error) { if containerName == "" { - return resp, fmt.Errorf("`containerName` cannot be an empty string") + err = fmt.Errorf("`containerName` cannot be an empty string") + return } if input.LeaseId == "" { - return resp, fmt.Errorf("`input.LeaseId` cannot be an empty string") + err = fmt.Errorf("`input.LeaseId` cannot be an empty string") + return } opts := client.RequestOptions{ @@ -37,12 +39,18 @@ func (c Client) ReleaseLease(ctx context.Context, containerName string, input Re }, Path: fmt.Sprintf("/%s", containerName), } + req, err := c.Client.NewRequest(ctx, opts) if err != nil { err = fmt.Errorf("building request: %+v", err) return } - resp.HttpResponse, err = req.Execute(ctx) + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/lease_renew.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/lease_renew.go index eda202989f23..38c948689996 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/lease_renew.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/lease_renew.go @@ -14,16 +14,18 @@ type RenewLeaseInput struct { } type RenewLeaseResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } // RenewLease renews the lock based on the Lease ID -func (c Client) RenewLease(ctx context.Context, containerName string, input RenewLeaseInput) (resp RenewLeaseResponse, err error) { +func (c Client) RenewLease(ctx context.Context, containerName string, input RenewLeaseInput) (result RenewLeaseResponse, err error) { if containerName == "" { - return resp, fmt.Errorf("`containerName` cannot be an empty string") + err = fmt.Errorf("`containerName` cannot be an empty string") + return } if input.LeaseId == "" { - return resp, fmt.Errorf("`input.LeaseId` cannot be an empty string") + err = fmt.Errorf("`input.LeaseId` cannot be an empty string") + return } opts := client.RequestOptions{ @@ -37,12 +39,18 @@ func (c Client) RenewLease(ctx context.Context, containerName string, input Rene }, Path: fmt.Sprintf("/%s", containerName), } + req, err := c.Client.NewRequest(ctx, opts) if err != nil { err = fmt.Errorf("building request: %+v", err) return } - resp.HttpResponse, err = req.Execute(ctx) + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/list_blobs.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/list_blobs.go index f3bd4674d30d..86ddc7c0a9df 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/list_blobs.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/list_blobs.go @@ -19,8 +19,9 @@ type ListBlobsInput struct { } type ListBlobsResponse struct { - HttpResponse *client.Response - Model *ListBlobsResult + ListBlobsResult + + HttpResponse *http.Response } type ListBlobsResult struct { @@ -80,12 +81,14 @@ type BlobPrefix struct { } // ListBlobs lists the blobs matching the specified query within the specified Container -func (c Client) ListBlobs(ctx context.Context, containerName string, input ListBlobsInput) (resp ListBlobsResponse, err error) { +func (c Client) ListBlobs(ctx context.Context, containerName string, input ListBlobsInput) (result ListBlobsResponse, err error) { if containerName == "" { - return resp, fmt.Errorf("`containerName` cannot be an empty string") + err = fmt.Errorf("`containerName` cannot be an empty string") + return } if input.MaxResults != nil && (*input.MaxResults <= 0 || *input.MaxResults > 5000) { - return resp, fmt.Errorf("`input.MaxResults` can either be nil or between 0 and 5000") + err = fmt.Errorf("`input.MaxResults` can either be nil or between 0 and 5000") + return } opts := client.RequestOptions{ ContentType: "application/xml; charset=utf-8", @@ -102,23 +105,28 @@ func (c Client) ListBlobs(ctx context.Context, containerName string, input ListB }, Path: fmt.Sprintf("/%s", containerName), } + req, err := c.Client.NewRequest(ctx, opts) if err != nil { err = fmt.Errorf("building request: %+v", err) return } - resp.HttpResponse, err = req.Execute(ctx) - if err != nil { - err = fmt.Errorf("executing request: %+v", err) - return - } - if resp.HttpResponse != nil { - if err = resp.HttpResponse.Unmarshal(&resp.Model); err != nil { - err = fmt.Errorf("unmarshaling response: %+v", err) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + err = resp.Unmarshal(&result) + if err != nil { + err = fmt.Errorf("unmarshalling response: %+v", err) return } } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } return } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/set_acl.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/set_acl.go index 642053735ff4..280ad4e391ff 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/set_acl.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/set_acl.go @@ -15,14 +15,15 @@ type SetAccessControlInput struct { } type SetAccessControlResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } // SetAccessControl sets the Access Control for a Container without a Lease ID // NOTE: The SetAccessControl operation only supports Shared Key authorization. -func (c Client) SetAccessControl(ctx context.Context, containerName string, input SetAccessControlInput) (resp SetAccessControlResponse, err error) { +func (c Client) SetAccessControl(ctx context.Context, containerName string, input SetAccessControlInput) (result SetAccessControlResponse, err error) { if containerName == "" { - return resp, fmt.Errorf("`containerName` cannot be an empty string") + err = fmt.Errorf("`containerName` cannot be an empty string") + return } opts := client.RequestOptions{ @@ -37,12 +38,18 @@ func (c Client) SetAccessControl(ctx context.Context, containerName string, inpu }, Path: fmt.Sprintf("/%s", containerName), } + req, err := c.Client.NewRequest(ctx, opts) if err != nil { err = fmt.Errorf("building request: %+v", err) return } - resp.HttpResponse, err = req.Execute(ctx) + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/set_metadata.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/set_metadata.go index 578c9a169558..3f8bb07e2819 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/set_metadata.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/set_metadata.go @@ -16,16 +16,18 @@ type SetMetaDataInput struct { } type SetMetaDataResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } // SetMetaData sets the specified MetaData on the Container without a Lease ID -func (c Client) SetMetaData(ctx context.Context, containerName string, input SetMetaDataInput) (resp SetMetaDataResponse, err error) { +func (c Client) SetMetaData(ctx context.Context, containerName string, input SetMetaDataInput) (result SetMetaDataResponse, err error) { if containerName == "" { - return resp, fmt.Errorf("`containerName` cannot be an empty string") + err = fmt.Errorf("`containerName` cannot be an empty string") + return } - if err := metadata.Validate(input.MetaData); err != nil { - return resp, fmt.Errorf("`input.MetaData` is not valid: %s", err) + if err = metadata.Validate(input.MetaData); err != nil { + err = fmt.Errorf("`input.MetaData` is not valid: %s", err) + return } opts := client.RequestOptions{ @@ -40,12 +42,18 @@ func (c Client) SetMetaData(ctx context.Context, containerName string, input Set }, Path: fmt.Sprintf("/%s", containerName), } + req, err := c.Client.NewRequest(ctx, opts) if err != nil { err = fmt.Errorf("building request: %+v", err) return } - resp.HttpResponse, err = req.Execute(ctx) + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/create.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/create.go index d0d4bab6321e..5bf1b66b5251 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/create.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/create.go @@ -18,14 +18,14 @@ type CreateInput struct { } type CreateResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } // Create creates a Data Lake Store Gen2 FileSystem within a Storage Account -func (c Client) Create(ctx context.Context, fileSystemName string, input CreateInput) (resp CreateResponse, err error) { - +func (c Client) Create(ctx context.Context, fileSystemName string, input CreateInput) (result CreateResponse, err error) { if fileSystemName == "" { - return resp, fmt.Errorf("`fileSystemName` cannot be an empty string") + err = fmt.Errorf("`fileSystemName` cannot be an empty string") + return } opts := client.RequestOptions{ @@ -42,12 +42,16 @@ func (c Client) Create(ctx context.Context, fileSystemName string, input CreateI } req, err := c.Client.NewRequest(ctx, opts) - if err != nil { err = fmt.Errorf("building request: %+v", err) return } - resp.HttpResponse, err = req.Execute(ctx) + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/delete.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/delete.go index a6d33b332801..6900f2899d35 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/delete.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/delete.go @@ -9,14 +9,14 @@ import ( ) type DeleteResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } // Delete deletes a Data Lake Store Gen2 FileSystem within a Storage Account -func (c Client) Delete(ctx context.Context, fileSystemName string) (resp DeleteResponse, err error) { - +func (c Client) Delete(ctx context.Context, fileSystemName string) (result DeleteResponse, err error) { if fileSystemName == "" { - return resp, fmt.Errorf("`fileSystemName` cannot be an empty string") + err = fmt.Errorf("`fileSystemName` cannot be an empty string") + return } opts := client.RequestOptions{ @@ -28,12 +28,18 @@ func (c Client) Delete(ctx context.Context, fileSystemName string) (resp DeleteR OptionsObject: fileSystemOptions{}, Path: fmt.Sprintf("/%s", fileSystemName), } + req, err := c.Client.NewRequest(ctx, opts) if err != nil { err = fmt.Errorf("building request: %+v", err) return } - resp.HttpResponse, err = req.Execute(ctx) + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/helpers.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/helpers.go index 605ed425929d..7822a128154e 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/helpers.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/helpers.go @@ -29,7 +29,7 @@ func parseProperties(input string) (*map[string]string, error) { // as such we can't string split on that -_- position := strings.Index(propertyRaw, "=") if position < 0 { - return nil, fmt.Errorf("Expected there to be an equals in the key value pair: %q", propertyRaw) + return nil, fmt.Errorf("expected an equal sign in the key value pair: %q", propertyRaw) } key := propertyRaw[0:position] diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/properties_get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/properties_get.go index e8e4a67d0a05..97512e6da5e8 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/properties_get.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/properties_get.go @@ -3,14 +3,13 @@ package filesystems import ( "context" "fmt" + "github.com/hashicorp/go-azure-sdk/sdk/client" "net/http" "strings" - - "github.com/hashicorp/go-azure-sdk/sdk/client" ) type GetPropertiesResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response // A map of base64-encoded strings to store as user-defined properties with the File System // Note that items may only contain ASCII characters in the ISO-8859-1 character set. @@ -23,10 +22,10 @@ type GetPropertiesResponse struct { } // GetProperties gets the properties for a Data Lake Store Gen2 FileSystem within a Storage Account -func (c Client) GetProperties(ctx context.Context, fileSystemName string) (resp GetPropertiesResponse, err error) { - +func (c Client) GetProperties(ctx context.Context, fileSystemName string) (result GetPropertiesResponse, err error) { if fileSystemName == "" { - return resp, fmt.Errorf("`fileSystemName` cannot be an empty string") + err = fmt.Errorf("`fileSystemName` cannot be an empty string") + return } opts := client.RequestOptions{ @@ -45,24 +44,27 @@ func (c Client) GetProperties(ctx context.Context, fileSystemName string) (resp return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if resp.Header != nil { + propertiesRaw := resp.Header.Get("x-ms-properties") + var properties *map[string]string + properties, err = parseProperties(propertiesRaw) + if err != nil { + return + } + + result.Properties = *properties + result.NamespaceEnabled = strings.EqualFold(resp.Header.Get("x-ms-namespace-enabled"), "true") + } + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return } - if resp.HttpResponse != nil { - - propertiesRaw := resp.HttpResponse.Header.Get("x-ms-properties") - var properties *map[string]string - properties, err = parseProperties(propertiesRaw) - if err != nil { - return - } - - resp.Properties = *properties - resp.NamespaceEnabled = strings.EqualFold(resp.HttpResponse.Header.Get("x-ms-namespace-enabled"), "true") - - } return } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/properties_set.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/properties_set.go index 82c259a236e8..775807aeb338 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/properties_set.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/properties_set.go @@ -26,14 +26,14 @@ type SetPropertiesInput struct { } type SetPropertiesResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } // SetProperties sets the Properties for a Data Lake Store Gen2 FileSystem within a Storage Account -func (c Client) SetProperties(ctx context.Context, fileSystemName string, input SetPropertiesInput) (resp SetPropertiesResponse, err error) { - +func (c Client) SetProperties(ctx context.Context, fileSystemName string, input SetPropertiesInput) (result SetPropertiesResponse, err error) { if fileSystemName == "" { - return resp, fmt.Errorf("`fileSystemName` cannot be an empty string") + err = fmt.Errorf("`fileSystemName` cannot be an empty string") + return } opts := client.RequestOptions{ @@ -52,12 +52,16 @@ func (c Client) SetProperties(ctx context.Context, fileSystemName string, input } req, err := c.Client.NewRequest(ctx, opts) - if err != nil { err = fmt.Errorf("building request: %+v", err) return } - resp.HttpResponse, err = req.Execute(ctx) + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/paths/create.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/paths/create.go index c95ea17ba1a5..8db9b66413eb 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/paths/create.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/paths/create.go @@ -19,14 +19,14 @@ type CreateInput struct { } type CreateResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } // Create creates a Data Lake Store Gen2 Path within a Storage Account -func (c Client) Create(ctx context.Context, fileSystemName string, path string, input CreateInput) (resp CreateResponse, err error) { +func (c Client) Create(ctx context.Context, fileSystemName string, path string, input CreateInput) (result CreateResponse, err error) { if fileSystemName == "" { - return resp, fmt.Errorf("`fileSystemName` cannot be an empty string") + return result, fmt.Errorf("`fileSystemName` cannot be an empty string") } opts := client.RequestOptions{ @@ -46,12 +46,17 @@ func (c Client) Create(ctx context.Context, fileSystemName string, path string, if err != nil { err = fmt.Errorf("building request: %+v", err) - return resp, err + return result, err + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response } - resp.HttpResponse, err = req.Execute(ctx) if err != nil { err = fmt.Errorf("executing request: %+v", err) - return resp, err + return result, err } return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/paths/delete.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/paths/delete.go index 4ea6e9312cdb..990be5157dc9 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/paths/delete.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/paths/delete.go @@ -9,14 +9,14 @@ import ( ) type DeleteResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } // Delete deletes a Data Lake Store Gen2 FileSystem within a Storage Account -func (c Client) Delete(ctx context.Context, fileSystemName string, path string) (resp DeleteResponse, err error) { +func (c Client) Delete(ctx context.Context, fileSystemName string, path string) (result DeleteResponse, err error) { if fileSystemName == "" { - return resp, fmt.Errorf("`fileSystemName` cannot be an empty string") + return result, fmt.Errorf("`fileSystemName` cannot be an empty string") } opts := client.RequestOptions{ @@ -33,7 +33,12 @@ func (c Client) Delete(ctx context.Context, fileSystemName string, path string) err = fmt.Errorf("building request: %+v", err) return } - resp.HttpResponse, err = req.Execute(ctx) + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/paths/helpers.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/paths/helpers.go index e6ef6f4bfb9f..08d893c2b81d 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/paths/helpers.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/paths/helpers.go @@ -11,5 +11,5 @@ func parsePathResource(input string) (PathResource, error) { case "directory": return PathResourceDirectory, nil } - return "", fmt.Errorf("Unhandled path resource type %q", input) + return "", fmt.Errorf("unhandled path resource type %q", input) } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/paths/properties_get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/paths/properties_get.go index ed911bd88d68..f5dcb782a5a4 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/paths/properties_get.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/paths/properties_get.go @@ -11,7 +11,7 @@ import ( ) type GetPropertiesResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response ETag string LastModified time.Time @@ -35,9 +35,10 @@ const ( ) // GetProperties gets the properties for a Data Lake Store Gen2 Path in a FileSystem within a Storage Account -func (c Client) GetProperties(ctx context.Context, fileSystemName string, path string, input GetPropertiesInput) (resp GetPropertiesResponse, err error) { +func (c Client) GetProperties(ctx context.Context, fileSystemName string, path string, input GetPropertiesInput) (result GetPropertiesResponse, err error) { if fileSystemName == "" { - return resp, fmt.Errorf("`fileSystemName` cannot be an empty string") + err = fmt.Errorf("`fileSystemName` cannot be an empty string") + return } opts := client.RequestOptions{ @@ -56,31 +57,36 @@ func (c Client) GetProperties(ctx context.Context, fileSystemName string, path s if err != nil { err = fmt.Errorf("building request: %+v", err) - return resp, err + return result, err } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if resp.Header != nil { + result.ResourceType = PathResource(resp.Header.Get("x-ms-resource-type")) + result.ETag = resp.Header.Get("ETag") + + if lastModifiedRaw := resp.Header.Get("Last-Modified"); lastModifiedRaw != "" { + lastModified, err := time.Parse(time.RFC1123, lastModifiedRaw) + if err != nil { + return GetPropertiesResponse{}, err + } + result.LastModified = lastModified + } + + result.Owner = resp.Header.Get("x-ms-owner") + result.Group = resp.Header.Get("x-ms-group") + result.ACL = resp.Header.Get("x-ms-acl") + } + } if err != nil { err = fmt.Errorf("executing request: %+v", err) - return resp, err + return result, err } - if resp.HttpResponse != nil { - resp.ResourceType = PathResource(resp.HttpResponse.Header.Get("x-ms-resource-type")) - resp.ETag = resp.HttpResponse.Header.Get("ETag") - - if lastModifiedRaw := resp.HttpResponse.Header.Get("Last-Modified"); lastModifiedRaw != "" { - lastModified, err := time.Parse(time.RFC1123, lastModifiedRaw) - if err != nil { - return GetPropertiesResponse{}, err - } - resp.LastModified = lastModified - } - - resp.Owner = resp.HttpResponse.Header.Get("x-ms-owner") - resp.Group = resp.HttpResponse.Header.Get("x-ms-group") - resp.ACL = resp.HttpResponse.Header.Get("x-ms-acl") - } return } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/paths/properties_set.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/paths/properties_set.go index 055f199cbc87..826e0ef46ce9 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/paths/properties_set.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/paths/properties_set.go @@ -24,14 +24,14 @@ type SetAccessControlInput struct { } type SetPropertiesResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } // SetProperties 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) (resp SetPropertiesResponse, err error) { - +func (c Client) SetAccessControl(ctx context.Context, fileSystemName string, path string, input SetAccessControlInput) (result SetPropertiesResponse, err error) { if fileSystemName == "" { - return resp, fmt.Errorf("`fileSystemName` cannot be an empty string") + err = fmt.Errorf("`fileSystemName` cannot be an empty string") + return } opts := client.RequestOptions{ @@ -50,13 +50,17 @@ func (c Client) SetAccessControl(ctx context.Context, fileSystemName string, pat if err != nil { err = fmt.Errorf("building request: %+v", err) - return resp, err + return result, err } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) - return resp, err + return result, err } return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/create.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/create.go index 7f63f9f87737..fdca3cf3f9a9 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/create.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/create.go @@ -28,26 +28,30 @@ type CreateDirectoryInput struct { } type CreateDirectoryResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } // Create creates a new directory under the specified share or parent directory. -func (c Client) Create(ctx context.Context, shareName, path string, input CreateDirectoryInput) (resp CreateDirectoryResponse, err error) { +func (c Client) Create(ctx context.Context, shareName, path string, input CreateDirectoryInput) (result CreateDirectoryResponse, err error) { if shareName == "" { - return resp, fmt.Errorf("`shareName` cannot be an empty string") + err = fmt.Errorf("`shareName` cannot be an empty string") + return } if strings.ToLower(shareName) != shareName { - return resp, fmt.Errorf("`shareName` must be a lower-cased string") + err = fmt.Errorf("`shareName` must be a lower-cased string") + return } if err = metadata.Validate(input.MetaData); err != nil { - return resp, fmt.Errorf("`input.MetaData` is not valid: %s", err) + err = fmt.Errorf("`input.MetaData` is not valid: %s", err) + return } if path == "" { - return resp, fmt.Errorf("`path` cannot be an empty string") + err = fmt.Errorf("`path` cannot be an empty string") + return } opts := client.RequestOptions{ @@ -68,7 +72,11 @@ func (c Client) Create(ctx context.Context, shareName, path string, input Create return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/delete.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/delete.go index fb96108862e4..35b7298307ae 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/delete.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/delete.go @@ -10,23 +10,26 @@ import ( ) type DeleteResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } // Delete removes the specified empty directory // Note that the directory must be empty before it can be deleted. -func (c Client) Delete(ctx context.Context, shareName, path string) (resp DeleteResponse, err error) { +func (c Client) Delete(ctx context.Context, shareName, path string) (result DeleteResponse, err error) { if shareName == "" { - return resp, fmt.Errorf("`shareName` cannot be an empty string") + err = fmt.Errorf("`shareName` cannot be an empty string") + return } if strings.ToLower(shareName) != shareName { - return resp, fmt.Errorf("`shareName` must be a lower-cased string") + err = fmt.Errorf("`shareName` must be a lower-cased string") + return } if path == "" { - return resp, fmt.Errorf("`path` cannot be an empty string") + err = fmt.Errorf("`path` cannot be an empty string") + return } opts := client.RequestOptions{ @@ -45,7 +48,11 @@ func (c Client) Delete(ctx context.Context, shareName, path string) (resp Delete return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/get.go index 5c900c4d10ff..2aeb03186f08 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/get.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/get.go @@ -11,7 +11,7 @@ import ( ) type GetResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response // A set of name-value pairs that contain metadata for the directory. MetaData map[string]string @@ -23,17 +23,20 @@ type GetResponse struct { // Get returns all system properties for the specified directory, // and can also be used to check the existence of a directory. -func (c Client) Get(ctx context.Context, shareName, path string) (resp GetResponse, err error) { +func (c Client) Get(ctx context.Context, shareName, path string) (result GetResponse, err error) { if shareName == "" { - return resp, fmt.Errorf("`shareName` cannot be an empty string") + err = fmt.Errorf("`shareName` cannot be an empty string") + return } if strings.ToLower(shareName) != shareName { - return resp, fmt.Errorf("`shareName` must be a lower-cased string") + err = fmt.Errorf("`shareName` must be a lower-cased string") + return } if path == "" { - return resp, fmt.Errorf("`path` cannot be an empty string") + err = fmt.Errorf("`path` cannot be an empty string") + return } opts := client.RequestOptions{ @@ -52,18 +55,20 @@ func (c Client) Get(ctx context.Context, shareName, path string) (resp GetRespon return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if resp.Header != nil { + result.DirectoryMetaDataEncrypted = strings.EqualFold(resp.Header.Get("x-ms-server-encrypted"), "true") + result.MetaData = metadata.ParseFromHeaders(resp.Header) + } + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return } - if resp.HttpResponse != nil { - if resp.HttpResponse.Header != nil { - resp.MetaData = metadata.ParseFromHeaders(resp.HttpResponse.Header) - } - resp.DirectoryMetaDataEncrypted = strings.EqualFold(resp.HttpResponse.Header.Get("x-ms-server-encrypted"), "true") - } - return } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/metadata_get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/metadata_get.go index 1911d39616f4..cfefeb5d5726 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/metadata_get.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/metadata_get.go @@ -12,23 +12,26 @@ import ( ) type GetMetaDataResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response MetaData map[string]string } // GetMetaData returns all user-defined metadata for the specified directory -func (c Client) GetMetaData(ctx context.Context, shareName, path string) (resp GetMetaDataResponse, err error) { +func (c Client) GetMetaData(ctx context.Context, shareName, path string) (result GetMetaDataResponse, err error) { if shareName == "" { - return resp, fmt.Errorf("`shareName` cannot be an empty string") + err = fmt.Errorf("`shareName` cannot be an empty string") + return } if strings.ToLower(shareName) != shareName { - return resp, fmt.Errorf("`shareName` must be a lower-cased string") + err = fmt.Errorf("`shareName` must be a lower-cased string") + return } if path == "" { - return resp, fmt.Errorf("`path` cannot be an empty string") + err = fmt.Errorf("`path` cannot be an empty string") + return } opts := client.RequestOptions{ @@ -47,18 +50,20 @@ func (c Client) GetMetaData(ctx context.Context, shareName, path string) (resp G return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if resp.Header != nil { + result.MetaData = metadata.ParseFromHeaders(resp.Header) + } + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return } - if resp.HttpResponse != nil { - if resp.HttpResponse.Header != nil { - resp.MetaData = metadata.ParseFromHeaders(resp.HttpResponse.Header) - } - } - return } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/metadata_set.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/metadata_set.go index 965f5ffef12a..8aa9097d3ef9 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/metadata_set.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/metadata_set.go @@ -12,7 +12,7 @@ import ( ) type SetMetaDataResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } type SetMetaDataInput struct { @@ -20,22 +20,26 @@ type SetMetaDataInput struct { } // SetMetaData updates user defined metadata for the specified directory -func (c Client) SetMetaData(ctx context.Context, shareName, path string, input SetMetaDataInput) (resp SetMetaDataResponse, err error) { +func (c Client) SetMetaData(ctx context.Context, shareName, path string, input SetMetaDataInput) (result SetMetaDataResponse, err error) { if shareName == "" { - return resp, fmt.Errorf("`shareName` cannot be an empty string") + err = fmt.Errorf("`shareName` cannot be an empty string") + return } if strings.ToLower(shareName) != shareName { - return resp, fmt.Errorf("`shareName` must be a lower-cased string") + err = fmt.Errorf("`shareName` must be a lower-cased string") + return } - if err := metadata.Validate(input.MetaData); err != nil { - return resp, fmt.Errorf("`metadata` is not valid: %s", err) + if err = metadata.Validate(input.MetaData); err != nil { + err = fmt.Errorf("`metadata` is not valid: %s", err) + return } if path == "" { - return resp, fmt.Errorf("`path` cannot be an empty string") + err = fmt.Errorf("`path` cannot be an empty string") + return } opts := client.RequestOptions{ @@ -56,7 +60,11 @@ func (c Client) SetMetaData(ctx context.Context, shareName, path string, input S return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/copy.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/copy.go index 577f95d60e30..d8351395df86 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/copy.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/copy.go @@ -25,7 +25,7 @@ type CopyInput struct { } type CopyResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response // The CopyID, which can be passed to AbortCopy to abort the copy. CopyID string @@ -35,26 +35,31 @@ type CopyResponse struct { } // Copy copies a blob or file to a destination file within the storage account asynchronously. -func (c Client) Copy(ctx context.Context, shareName, path, fileName string, input CopyInput) (resp CopyResponse, err error) { +func (c Client) Copy(ctx context.Context, shareName, path, fileName string, input CopyInput) (result CopyResponse, err error) { if shareName == "" { - return resp, fmt.Errorf("`shareName` cannot be an empty string") + err = fmt.Errorf("`shareName` cannot be an empty string") + return } if strings.ToLower(shareName) != shareName { - return resp, fmt.Errorf("`shareName` must be a lower-cased string") + err = fmt.Errorf("`shareName` must be a lower-cased string") + return } if fileName == "" { - return resp, fmt.Errorf("`fileName` cannot be an empty string") + err = fmt.Errorf("`fileName` cannot be an empty string") + return } if input.CopySource == "" { - return resp, fmt.Errorf("`input.CopySource` cannot be an empty string") + err = fmt.Errorf("`input.CopySource` cannot be an empty string") + return } if err = metadata.Validate(input.MetaData); err != nil { - return resp, fmt.Errorf("`input.MetaData` is not valid: %s", err) + err = fmt.Errorf("`input.MetaData` is not valid: %s", err) + return } if path != "" { @@ -78,19 +83,22 @@ func (c Client) Copy(ctx context.Context, shareName, path, fileName string, inpu err = fmt.Errorf("building request: %+v", err) return } - resp.HttpResponse, err = req.Execute(ctx) + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if resp.Header != nil { + result.CopyID = resp.Header.Get("x-ms-copy-id") + result.CopySuccess = resp.Header.Get("x-ms-copy-status") + } + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return } - if resp.HttpResponse != nil { - if resp.HttpResponse.Header != nil { - resp.CopyID = resp.HttpResponse.Header.Get("x-ms-copy-id") - resp.CopySuccess = resp.HttpResponse.Header.Get("x-ms-copy-status") - } - } - return } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/copy_abort.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/copy_abort.go index 55611602d37e..191929b8dab5 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/copy_abort.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/copy_abort.go @@ -15,26 +15,30 @@ type CopyAbortInput struct { } type CopyAbortResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } // AbortCopy aborts a pending Copy File operation, and leaves a destination file with zero length and full metadata -func (c Client) AbortCopy(ctx context.Context, shareName, path, fileName string, input CopyAbortInput) (resp CopyAbortResponse, err error) { +func (c Client) AbortCopy(ctx context.Context, shareName, path, fileName string, input CopyAbortInput) (result CopyAbortResponse, err error) { if shareName == "" { - return resp, fmt.Errorf("`shareName` cannot be an empty string") + err = fmt.Errorf("`shareName` cannot be an empty string") + return } if strings.ToLower(shareName) != shareName { - return resp, fmt.Errorf("`shareName` must be a lower-cased string") + err = fmt.Errorf("`shareName` must be a lower-cased string") + return } if fileName == "" { - return resp, fmt.Errorf("`fileName` cannot be an empty string") + err = fmt.Errorf("`fileName` cannot be an empty string") + return } if input.copyID == "" { - return resp, fmt.Errorf("`copyID` cannot be an empty string") + err = fmt.Errorf("`copyID` cannot be an empty string") + return } if path != "" { @@ -59,7 +63,11 @@ func (c Client) AbortCopy(ctx context.Context, shareName, path, fileName string, return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/copy_wait.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/copy_wait.go index 1ccb5f31e635..9223f54331ae 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/copy_wait.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/copy_wait.go @@ -9,20 +9,20 @@ import ( ) // CopyAndWait is a convenience method which doesn't exist in the API, which copies the file and then waits for the copy to complete -func (c Client) CopyAndWait(ctx context.Context, shareName, path, fileName string, input CopyInput) (resp CopyResponse, err error) { - copy, e := c.Copy(ctx, shareName, path, fileName, input) +func (c Client) CopyAndWait(ctx context.Context, shareName, path, fileName string, input CopyInput) (result CopyResponse, err error) { + fileCopy, e := c.Copy(ctx, shareName, path, fileName, input) if err != nil { - resp.HttpResponse = copy.HttpResponse - err = fmt.Errorf("error copying: %s", e) + result.HttpResponse = fileCopy.HttpResponse + err = fmt.Errorf("copying: %s", e) return } - resp.CopyID = copy.CopyID + result.CopyID = fileCopy.CopyID pollerType := NewCopyAndWaitPoller(&c, shareName, path, fileName) poller := pollers.NewPoller(pollerType, 10*time.Second, pollers.DefaultNumberOfDroppedConnectionsToAllow) - if err := poller.PollUntilDone(ctx); err != nil { - return resp, fmt.Errorf("waiting for file to copy: %+v", err) + if err = poller.PollUntilDone(ctx); err != nil { + return result, fmt.Errorf("waiting for file to copy: %+v", err) } return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/create.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/create.go index 7c08a85bc1f1..5fb8e97d2e8b 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/create.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/create.go @@ -51,25 +51,29 @@ type CreateInput struct { } type CreateResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } // Create creates a new file or replaces a file. -func (c Client) Create(ctx context.Context, shareName, path, fileName string, input CreateInput) (resp CreateResponse, err error) { +func (c Client) Create(ctx context.Context, shareName, path, fileName string, input CreateInput) (result CreateResponse, err error) { if shareName == "" { - return resp, fmt.Errorf("`shareName` cannot be an empty string") + err = fmt.Errorf("`shareName` cannot be an empty string") + return } if strings.ToLower(shareName) != shareName { - return resp, fmt.Errorf("`shareName` must be a lower-cased string") + err = fmt.Errorf("`shareName` must be a lower-cased string") + return } if fileName == "" { - return resp, fmt.Errorf("`fileName` cannot be an empty string") + err = fmt.Errorf("`fileName` cannot be an empty string") + return } if err = metadata.Validate(input.MetaData); err != nil { - return resp, fmt.Errorf("`input.MetaData` is not valid: %s", err) + err = fmt.Errorf("`input.MetaData` is not valid: %s", err) + return } if path != "" { @@ -94,7 +98,11 @@ func (c Client) Create(ctx context.Context, shareName, path, fileName string, in return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/delete.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/delete.go index d5e32405038f..f3841fa0427d 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/delete.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/delete.go @@ -10,22 +10,25 @@ import ( ) type DeleteResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } // Delete immediately deletes the file from the File Share. -func (c Client) Delete(ctx context.Context, shareName, path, fileName string) (resp DeleteResponse, err error) { +func (c Client) Delete(ctx context.Context, shareName, path, fileName string) (result DeleteResponse, err error) { if shareName == "" { - return resp, fmt.Errorf("`shareName` cannot be an empty string") + err = fmt.Errorf("`shareName` cannot be an empty string") + return } if strings.ToLower(shareName) != shareName { - return resp, fmt.Errorf("`shareName` must be a lower-cased string") + err = fmt.Errorf("`shareName` must be a lower-cased string") + return } if fileName == "" { - return resp, fmt.Errorf("`fileName` cannot be an empty string") + err = fmt.Errorf("`fileName` cannot be an empty string") + return } if path != "" { @@ -48,7 +51,11 @@ func (c Client) Delete(ctx context.Context, shareName, path, fileName string) (r return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/metadata_get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/metadata_get.go index 3e0fbad008ad..2cb510d5fa3f 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/metadata_get.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/metadata_get.go @@ -3,32 +3,35 @@ package files import ( "context" "fmt" + "github.com/tombuildsstuff/giovanni/storage/internal/metadata" "net/http" "strings" "github.com/hashicorp/go-azure-sdk/sdk/client" "github.com/hashicorp/go-azure-sdk/sdk/odata" - "github.com/tombuildsstuff/giovanni/storage/internal/metadata" ) type GetMetaDataResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response MetaData map[string]string } // GetMetaData returns the MetaData for the specified File. -func (c Client) GetMetaData(ctx context.Context, shareName, path, fileName string) (resp GetMetaDataResponse, err error) { +func (c Client) GetMetaData(ctx context.Context, shareName, path, fileName string) (result GetMetaDataResponse, err error) { if shareName == "" { - return resp, fmt.Errorf("`shareName` cannot be an empty string") + err = fmt.Errorf("`shareName` cannot be an empty string") + return } if strings.ToLower(shareName) != shareName { - return resp, fmt.Errorf("`shareName` must be a lower-cased string") + err = fmt.Errorf("`shareName` must be a lower-cased string") + return } if fileName == "" { - return resp, fmt.Errorf("`fileName` cannot be an empty string") + err = fmt.Errorf("`fileName` cannot be an empty string") + return } if path != "" { @@ -51,18 +54,20 @@ func (c Client) GetMetaData(ctx context.Context, shareName, path, fileName strin return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if resp.Header != nil { + result.MetaData = metadata.ParseFromHeaders(resp.Header) + } + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return } - if resp.HttpResponse != nil { - if resp.HttpResponse.Header != nil { - resp.MetaData = metadata.ParseFromHeaders(resp.HttpResponse.Header) - } - } - return } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/metadata_set.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/metadata_set.go index 4087ef58fdc7..3a51a1086bfd 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/metadata_set.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/metadata_set.go @@ -12,7 +12,7 @@ import ( ) type SetMetaDataResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } type SetMetaDataInput struct { @@ -20,21 +20,25 @@ type SetMetaDataInput struct { } // SetMetaData updates the specified File to have the specified MetaData. -func (c Client) SetMetaData(ctx context.Context, shareName, path, fileName string, input SetMetaDataInput) (resp SetMetaDataResponse, err error) { +func (c Client) SetMetaData(ctx context.Context, shareName, path, fileName string, input SetMetaDataInput) (result SetMetaDataResponse, err error) { if shareName == "" { - return resp, fmt.Errorf("`shareName` cannot be an empty string") + err = fmt.Errorf("`shareName` cannot be an empty string") + return } if strings.ToLower(shareName) != shareName { - return resp, fmt.Errorf("`shareName` must be a lower-cased string") + err = fmt.Errorf("`shareName` must be a lower-cased string") + return } if fileName == "" { - return resp, fmt.Errorf("`fileName` cannot be an empty string") + err = fmt.Errorf("`fileName` cannot be an empty string") + return } if err = metadata.Validate(input.MetaData); err != nil { - return resp, fmt.Errorf("`input.MetaData` is not valid: %s", err) + err = fmt.Errorf("`input.MetaData` is not valid: %s", err) + return } if path != "" { @@ -59,7 +63,11 @@ func (c Client) SetMetaData(ctx context.Context, shareName, path, fileName strin return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/properties_get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/properties_get.go index 6a21f7784940..2bfea4784421 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/properties_get.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/properties_get.go @@ -3,16 +3,16 @@ package files import ( "context" "fmt" + "github.com/tombuildsstuff/giovanni/storage/internal/metadata" "net/http" "strconv" "strings" "github.com/hashicorp/go-azure-sdk/sdk/client" - "github.com/tombuildsstuff/giovanni/storage/internal/metadata" ) type GetResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response CacheControl string ContentDisposition string @@ -33,17 +33,20 @@ type GetResponse struct { } // GetProperties returns the Properties for the specified file -func (c Client) GetProperties(ctx context.Context, shareName, path, fileName string) (resp GetResponse, err error) { +func (c Client) GetProperties(ctx context.Context, shareName, path, fileName string) (result GetResponse, err error) { if shareName == "" { - return resp, fmt.Errorf("`shareName` cannot be an empty string") + err = fmt.Errorf("`shareName` cannot be an empty string") + return } if strings.ToLower(shareName) != shareName { - return resp, fmt.Errorf("`shareName` must be a lower-cased string") + err = fmt.Errorf("`shareName` must be a lower-cased string") + return } if fileName == "" { - return resp, fmt.Errorf("`fileName` cannot be an empty string") + err = fmt.Errorf("`fileName` cannot be an empty string") + return } if path != "" { @@ -66,40 +69,44 @@ func (c Client) GetProperties(ctx context.Context, shareName, path, fileName str return } - resp.HttpResponse, err = req.Execute(ctx) - if err != nil { - err = fmt.Errorf("executing request: %+v", err) - return - } + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response - if resp.HttpResponse != nil { - if resp.HttpResponse.Header != nil { - resp.CacheControl = resp.HttpResponse.Header.Get("Cache-Control") - resp.ContentDisposition = resp.HttpResponse.Header.Get("Content-Disposition") - resp.ContentEncoding = resp.HttpResponse.Header.Get("Content-Encoding") - resp.ContentLanguage = resp.HttpResponse.Header.Get("Content-Language") - resp.ContentMD5 = resp.HttpResponse.Header.Get("Content-MD5") - resp.ContentType = resp.HttpResponse.Header.Get("Content-Type") - resp.CopyID = resp.HttpResponse.Header.Get("x-ms-copy-id") - resp.CopyProgress = resp.HttpResponse.Header.Get("x-ms-copy-progress") - resp.CopySource = resp.HttpResponse.Header.Get("x-ms-copy-source") - resp.CopyStatus = resp.HttpResponse.Header.Get("x-ms-copy-status") - resp.CopyStatusDescription = resp.HttpResponse.Header.Get("x-ms-copy-status-description") - resp.CopyCompletionTime = resp.HttpResponse.Header.Get("x-ms-copy-completion-time") - resp.Encrypted = strings.EqualFold(resp.HttpResponse.Header.Get("x-ms-server-encrypted"), "true") - resp.MetaData = metadata.ParseFromHeaders(resp.HttpResponse.Header) + 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") + result.ContentLanguage = resp.Header.Get("Content-Language") + result.ContentMD5 = resp.Header.Get("Content-MD5") + result.ContentType = resp.Header.Get("Content-Type") + result.CopyCompletionTime = resp.Header.Get("x-ms-copy-completion-time") + result.CopyID = resp.Header.Get("x-ms-copy-id") + result.CopyProgress = resp.Header.Get("x-ms-copy-progress") + result.CopySource = resp.Header.Get("x-ms-copy-source") + result.CopyStatus = resp.Header.Get("x-ms-copy-status") + result.CopyStatusDescription = resp.Header.Get("x-ms-copy-status-description") + result.Encrypted = strings.EqualFold(resp.Header.Get("x-ms-server-encrypted"), "true") + result.MetaData = metadata.ParseFromHeaders(resp.Header) - contentLengthRaw := resp.HttpResponse.Header.Get("Content-Length") + contentLengthRaw := resp.Header.Get("Content-Length") if contentLengthRaw != "" { - contentLength, err := strconv.Atoi(contentLengthRaw) + var contentLength int + contentLength, err = strconv.Atoi(contentLengthRaw) if err != nil { - return resp, fmt.Errorf("error parsing %q for Content-Length as an integer: %s", contentLengthRaw, err) + err = fmt.Errorf("parsing %q for Content-Length as an integer: %s", contentLengthRaw, err) + return } contentLengthI64 := int64(contentLength) - resp.ContentLength = &contentLengthI64 + result.ContentLength = &contentLengthI64 } } } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } return } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/properties_set.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/properties_set.go index 0e2c547a8d96..83bd84118eb5 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/properties_set.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/properties_set.go @@ -68,21 +68,24 @@ type SetPropertiesInput struct { } type SetPropertiesResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } // SetProperties sets the specified properties on the specified File -func (c Client) SetProperties(ctx context.Context, shareName, path, fileName string, input SetPropertiesInput) (resp SetPropertiesResponse, err error) { +func (c Client) SetProperties(ctx context.Context, shareName, path, fileName string, input SetPropertiesInput) (result SetPropertiesResponse, err error) { if shareName == "" { - return resp, fmt.Errorf("`shareName` cannot be an empty string") + err = fmt.Errorf("`shareName` cannot be an empty string") + return } if strings.ToLower(shareName) != shareName { - return resp, fmt.Errorf("`shareName` must be a lower-cased string") + err = fmt.Errorf("`shareName` must be a lower-cased string") + return } if fileName == "" { - return resp, fmt.Errorf("`fileName` cannot be an empty string") + err = fmt.Errorf("`fileName` cannot be an empty string") + return } if path != "" { @@ -107,7 +110,11 @@ func (c Client) SetProperties(ctx context.Context, shareName, path, fileName str return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/range_clear.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/range_clear.go index c2391a1c9c04..0a1e8149ed73 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/range_clear.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/range_clear.go @@ -16,30 +16,35 @@ type ClearByteRangeInput struct { } type ClearByteRangeResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } // ClearByteRange clears the specified Byte Range from within the specified File -func (c Client) ClearByteRange(ctx context.Context, shareName, path, fileName string, input ClearByteRangeInput) (resp ClearByteRangeResponse, err error) { +func (c Client) ClearByteRange(ctx context.Context, shareName, path, fileName string, input ClearByteRangeInput) (result ClearByteRangeResponse, err error) { if shareName == "" { - return resp, fmt.Errorf("`shareName` cannot be an empty string") + err = fmt.Errorf("`shareName` cannot be an empty string") + return } if strings.ToLower(shareName) != shareName { - return resp, fmt.Errorf("`shareName` must be a lower-cased string") + err = fmt.Errorf("`shareName` must be a lower-cased string") + return } if fileName == "" { - return resp, fmt.Errorf("`fileName` cannot be an empty string") + err = fmt.Errorf("`fileName` cannot be an empty string") + return } if input.StartBytes < 0 { - return resp, fmt.Errorf("`input.StartBytes` must be greater or equal to 0") + err = fmt.Errorf("`input.StartBytes` must be greater or equal to 0") + return } if input.EndBytes <= 0 { - return resp, fmt.Errorf("`input.EndBytes` must be greater than 0") + err = fmt.Errorf("`input.EndBytes` must be greater than 0") + return } if path != "" { @@ -64,7 +69,11 @@ func (c Client) ClearByteRange(ctx context.Context, shareName, path, fileName st return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/range_get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/range_get.go index 90a1089b3798..b6056628668a 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/range_get.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/range_get.go @@ -17,40 +17,47 @@ type GetByteRangeInput struct { } type GetByteRangeResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response Contents []byte } // GetByteRange returns the specified Byte Range from the specified File. -func (c Client) GetByteRange(ctx context.Context, shareName, path, fileName string, input GetByteRangeInput) (resp GetByteRangeResponse, err error) { +func (c Client) GetByteRange(ctx context.Context, shareName, path, fileName string, input GetByteRangeInput) (result GetByteRangeResponse, err error) { if shareName == "" { - return resp, fmt.Errorf("`shareName` cannot be an empty string") + err = fmt.Errorf("`shareName` cannot be an empty string") + return } if strings.ToLower(shareName) != shareName { - return resp, fmt.Errorf("`shareName` must be a lower-cased string") + err = fmt.Errorf("`shareName` must be a lower-cased string") + return } if fileName == "" { - return resp, fmt.Errorf("`fileName` cannot be an empty string") + err = fmt.Errorf("`fileName` cannot be an empty string") + return } if input.StartBytes < 0 { - return resp, fmt.Errorf("`input.StartBytes` must be greater or equal to 0") + err = fmt.Errorf("`input.StartBytes` must be greater or equal to 0") + return } if input.EndBytes <= 0 { - return resp, fmt.Errorf("`input.EndBytes` must be greater than 0") + err = fmt.Errorf("`input.EndBytes` must be greater than 0") + return } expectedBytes := input.EndBytes - input.StartBytes if expectedBytes < (4 * 1024) { - return resp, fmt.Errorf("requested Byte Range must be at least 4KB") + err = fmt.Errorf("requested Byte Range must be at least 4KB") + return } if expectedBytes > (4 * 1024 * 1024) { - return resp, fmt.Errorf("requested Byte Range must be at most 4MB") + err = fmt.Errorf("requested Byte Range must be at most 4MB") + return } if path != "" { @@ -75,20 +82,21 @@ func (c Client) GetByteRange(ctx context.Context, shareName, path, fileName stri return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if result.Contents, err = io.ReadAll(resp.Body); err != nil { + err = fmt.Errorf("reading response body: %+v", err) + return + } + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return } - if resp.HttpResponse != nil { - bytes, err := io.ReadAll(resp.HttpResponse.Body) - if err != nil { - return resp, fmt.Errorf("reading response body: %v", err) - } - resp.Contents = bytes - } - return } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/range_get_file.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/range_get_file.go index f81852604283..08589434f7fe 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/range_get_file.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/range_get_file.go @@ -5,10 +5,9 @@ import ( "fmt" "log" "math" + "net/http" "runtime" "sync" - - "github.com/hashicorp/go-azure-sdk/sdk/client" ) type GetFileInput struct { @@ -16,18 +15,18 @@ type GetFileInput struct { } type GetFileResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response OutputBytes []byte } // GetFile is a helper method to download a file by chunking it automatically -func (c Client) GetFile(ctx context.Context, shareName, path, fileName string, input GetFileInput) (resp GetFileResponse, err error) { +func (c Client) GetFile(ctx context.Context, shareName, path, fileName string, input GetFileInput) (result GetFileResponse, err error) { // first look up the file and check out how many bytes it is file, e := c.GetProperties(ctx, shareName, path, fileName) if err != nil { - resp.HttpResponse = file.HttpResponse + result.HttpResponse = file.HttpResponse err = e return } @@ -37,7 +36,7 @@ func (c Client) GetFile(ctx context.Context, shareName, path, fileName string, i return } - resp.HttpResponse = file.HttpResponse + result.HttpResponse = file.HttpResponse length := *file.ContentLength chunkSize := int64(4 * 1024 * 1024) // 4MB @@ -95,7 +94,7 @@ func (c Client) GetFile(ctx context.Context, shareName, path, fileName string, i copy(output[v.startBytes:v.endBytes], v.bytes) } - resp.OutputBytes = output + result.OutputBytes = output return } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/range_put.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/range_put.go index 7588f8b4131e..58e6f9bb0cff 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/range_put.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/range_put.go @@ -23,39 +23,45 @@ type PutByteRangeInput struct { } type PutRangeResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } // PutByteRange puts the specified Byte Range in the specified File. -func (c Client) PutByteRange(ctx context.Context, shareName, path, fileName string, input PutByteRangeInput) (resp PutRangeResponse, err error) { - +func (c Client) PutByteRange(ctx context.Context, shareName, path, fileName string, input PutByteRangeInput) (result PutRangeResponse, err error) { if shareName == "" { - return resp, fmt.Errorf("`shareName` cannot be an empty string") + err = fmt.Errorf("`shareName` cannot be an empty string") + return } if strings.ToLower(shareName) != shareName { - return resp, fmt.Errorf("`shareName` must be a lower-cased string") + err = fmt.Errorf("`shareName` must be a lower-cased string") + return } if fileName == "" { - return resp, fmt.Errorf("`fileName` cannot be an empty string") + err = fmt.Errorf("`fileName` cannot be an empty string") + return } if input.StartBytes < 0 { - return resp, fmt.Errorf("`input.StartBytes` must be greater or equal to 0") + err = fmt.Errorf("`input.StartBytes` must be greater or equal to 0") + return } if input.EndBytes <= 0 { - return resp, fmt.Errorf("`input.EndBytes` must be greater than 0") + err = fmt.Errorf("`input.EndBytes` must be greater than 0") + return } expectedBytes := input.EndBytes - input.StartBytes actualBytes := len(input.Content) if expectedBytes != int64(actualBytes) { - return resp, fmt.Errorf(fmt.Sprintf("The specified byte-range (%d) didn't match the content size (%d).", expectedBytes, actualBytes)) + err = fmt.Errorf(fmt.Sprintf("The specified byte-range (%d) didn't match the content size (%d).", expectedBytes, actualBytes)) + return } if expectedBytes > (4 * 1024 * 1024) { - return resp, fmt.Errorf("specified Byte Range must be at most 4MB") + err = fmt.Errorf("specified Byte Range must be at most 4MB") + return } if path != "" { @@ -82,7 +88,11 @@ func (c Client) PutByteRange(ctx context.Context, shareName, path, fileName stri req.Body = io.NopCloser(bytes.NewReader(input.Content)) req.ContentLength = int64(len(input.Content)) - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/range_put_file.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/range_put_file.go index cad6f557b442..660122c1aa8f 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/range_put_file.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/range_put_file.go @@ -66,7 +66,7 @@ func (c Client) PutFile(ctx context.Context, shareName, path, fileName string, f // TODO: we should switch to hashicorp/multi-error here if len(errors) > 0 { - return fmt.Errorf("Error uploading file: %s", <-errors) + return fmt.Errorf("uploading file: %s", <-errors) } return nil @@ -94,7 +94,7 @@ func (c Client) uploadChunk(ctx context.Context, shareName, path, fileName strin _, err = file.ReadAt(bytes, startBytes) if err != nil { if err != io.EOF { - return result, fmt.Errorf("Error reading bytes: %s", err) + return result, fmt.Errorf("reading bytes: %s", err) } } @@ -105,7 +105,7 @@ func (c Client) uploadChunk(ctx context.Context, shareName, path, fileName strin } result, err = c.PutByteRange(ctx, shareName, path, fileName, putBytesInput) if err != nil { - return result, fmt.Errorf("error putting bytes: %s", err) + return result, fmt.Errorf("putting bytes: %s", err) } return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/ranges_list.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/ranges_list.go index 9a67cab82857..0b89e6c1a110 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/ranges_list.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/ranges_list.go @@ -11,7 +11,7 @@ import ( ) type ListRangesResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response Ranges []Range `xml:"Range"` } @@ -22,22 +22,25 @@ type Range struct { } // ListRanges returns the list of valid ranges for the specified File. -func (c Client) ListRanges(ctx context.Context, shareName, path, fileName string) (resp ListRangesResponse, err error) { - +func (c Client) ListRanges(ctx context.Context, shareName, path, fileName string) (result ListRangesResponse, err error) { if shareName == "" { - return resp, fmt.Errorf("`shareName` cannot be an empty string") + err = fmt.Errorf("`shareName` cannot be an empty string") + return } if strings.ToLower(shareName) != shareName { - return resp, fmt.Errorf("`shareName` must be a lower-cased string") + err = fmt.Errorf("`shareName` must be a lower-cased string") + return } if path == "" { - return resp, fmt.Errorf("`path` cannot be an empty string") + err = fmt.Errorf("`path` cannot be an empty string") + return } if fileName == "" { - return resp, fmt.Errorf("`fileName` cannot be an empty string") + err = fmt.Errorf("`fileName` cannot be an empty string") + return } if path != "" { @@ -60,16 +63,22 @@ func (c Client) ListRanges(ctx context.Context, shareName, path, fileName string return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + err = resp.Unmarshal(&result) + if err != nil { + err = fmt.Errorf("unmarshalling response: %+v", err) + return + } + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return } - if resp.HttpResponse != nil { - resp.HttpResponse.Unmarshal(&resp) - } - return } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/acl_get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/acl_get.go index 56aa6413d4b8..8add483a5e3e 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/acl_get.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/acl_get.go @@ -11,19 +11,20 @@ import ( ) type GetACLResult struct { - HttpResponse *client.Response + HttpResponse *http.Response SignedIdentifiers []SignedIdentifier `xml:"SignedIdentifier"` } // GetACL get the Access Control List for the specified Storage Share -func (c Client) GetACL(ctx context.Context, shareName string) (resp GetACLResult, err error) { - +func (c Client) GetACL(ctx context.Context, shareName string) (result GetACLResult, err error) { if shareName == "" { - return resp, fmt.Errorf("`shareName` cannot be an empty string") + err = fmt.Errorf("`shareName` cannot be an empty string") + return } if strings.ToLower(shareName) != shareName { - return resp, fmt.Errorf("`shareName` must be a lower-cased string") + err = fmt.Errorf("`shareName` must be a lower-cased string") + return } opts := client.RequestOptions{ @@ -42,18 +43,22 @@ func (c Client) GetACL(ctx context.Context, shareName string) (resp GetACLResult return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + err = resp.Unmarshal(&result) + if err != nil { + err = fmt.Errorf("unmarshalling response: %+v", err) + return + } + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return } - if resp.HttpResponse != nil { - err = resp.HttpResponse.Unmarshal(&resp) - if err != nil { - return resp, fmt.Errorf("unmarshalling response: %v", err) - } - } return } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/acl_set.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/acl_set.go index 33b7c84a47d0..58e87bc4fb16 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/acl_set.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/acl_set.go @@ -15,7 +15,7 @@ import ( ) type SetAclResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } type SetAclInput struct { @@ -25,14 +25,15 @@ type SetAclInput struct { } // SetACL sets the specified Access Control List on the specified Storage Share -func (c Client) SetACL(ctx context.Context, shareName string, input SetAclInput) (resp SetAclResponse, err error) { - +func (c Client) SetACL(ctx context.Context, shareName string, input SetAclInput) (result SetAclResponse, err error) { if shareName == "" { - return resp, fmt.Errorf("`shareName` cannot be an empty string") + err = fmt.Errorf("`shareName` cannot be an empty string") + return } if strings.ToLower(shareName) != shareName { - return resp, fmt.Errorf("`shareName` must be a lower-cased string") + err = fmt.Errorf("`shareName` must be a lower-cased string") + return } opts := client.RequestOptions{ @@ -53,7 +54,8 @@ func (c Client) SetACL(ctx context.Context, shareName string, input SetAclInput) b, err := xml.Marshal(&input) if err != nil { - return resp, fmt.Errorf("marshalling input: %v", err) + err = fmt.Errorf("marshalling input: %+v", err) + return } withHeader := xml.Header + string(b) bytesWithHeader := []byte(withHeader) @@ -61,11 +63,16 @@ func (c Client) SetACL(ctx context.Context, shareName string, input SetAclInput) req.Header.Set("Content-Length", strconv.Itoa(len(bytesWithHeader))) req.Body = io.NopCloser(bytes.NewReader(bytesWithHeader)) - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return } + return } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/create.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/create.go index b0184600af0e..fdf13e330258 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/create.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/create.go @@ -36,26 +36,30 @@ type CreateInput struct { } type CreateResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } // Create creates the specified Storage Share within the specified Storage Account -func (c Client) Create(ctx context.Context, shareName string, input CreateInput) (resp CreateResponse, err error) { +func (c Client) Create(ctx context.Context, shareName string, input CreateInput) (result CreateResponse, err error) { if shareName == "" { - return resp, fmt.Errorf("`shareName` cannot be an empty string") + err = fmt.Errorf("`shareName` cannot be an empty string") + return } if strings.ToLower(shareName) != shareName { - return resp, fmt.Errorf("`shareName` must be a lower-cased string") + err = fmt.Errorf("`shareName` must be a lower-cased string") + return } if input.QuotaInGB <= 0 || input.QuotaInGB > 102400 { - return resp, fmt.Errorf("`input.QuotaInGB` must be greater than 0, and less than/equal to 100TB (102400 GB)") + err = fmt.Errorf("`input.QuotaInGB` must be greater than 0, and less than/equal to 100TB (102400 GB)") + return } if err = metadata.Validate(input.MetaData); err != nil { - return resp, fmt.Errorf("`input.MetaData` is not valid: %s", err) + err = fmt.Errorf("`input.MetaData` is not valid: %s", err) + return } opts := client.RequestOptions{ @@ -74,11 +78,17 @@ func (c Client) Create(ctx context.Context, shareName string, input CreateInput) err = fmt.Errorf("building request: %+v", err) return } - resp.HttpResponse, err = req.Execute(ctx) + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return } + return } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/delete.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/delete.go index 7ae11b3dbef3..84667f68a3ef 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/delete.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/delete.go @@ -11,7 +11,7 @@ import ( ) type DeleteResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } type DeleteInput struct { @@ -19,13 +19,15 @@ type DeleteInput struct { } // Delete deletes the specified Storage Share from within a Storage Account -func (c Client) Delete(ctx context.Context, shareName string, input DeleteInput) (resp DeleteResponse, err error) { +func (c Client) Delete(ctx context.Context, shareName string, input DeleteInput) (result DeleteResponse, err error) { if shareName == "" { - return resp, fmt.Errorf("`shareName` cannot be an empty string") + err = fmt.Errorf("`shareName` cannot be an empty string") + return } if strings.ToLower(shareName) != shareName { - return resp, fmt.Errorf("`shareName` must be a lower-cased string") + err = fmt.Errorf("`shareName` must be a lower-cased string") + return } opts := client.RequestOptions{ @@ -45,7 +47,11 @@ func (c Client) Delete(ctx context.Context, shareName string, input DeleteInput) return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/metadata_get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/metadata_get.go index e31762bd2d8a..eeb8b4d1e7dc 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/metadata_get.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/metadata_get.go @@ -12,18 +12,18 @@ import ( ) type GetMetaDataResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response MetaData map[string]string } // GetMetaData returns the MetaData associated with the specified Storage Share -func (c Client) GetMetaData(ctx context.Context, shareName string) (resp GetMetaDataResponse, err error) { +func (c Client) GetMetaData(ctx context.Context, shareName string) (result GetMetaDataResponse, err error) { if shareName == "" { - return resp, fmt.Errorf("`shareName` cannot be an empty string") + return result, fmt.Errorf("`shareName` cannot be an empty string") } if strings.ToLower(shareName) != shareName { - return resp, fmt.Errorf("`shareName` must be a lower-cased string") + return result, fmt.Errorf("`shareName` must be a lower-cased string") } opts := client.RequestOptions{ @@ -42,18 +42,20 @@ func (c Client) GetMetaData(ctx context.Context, shareName string) (resp GetMeta return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if resp.Header != nil { + result.MetaData = metadata.ParseFromHeaders(resp.Header) + } + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return } - if resp.HttpResponse != nil { - if resp.HttpResponse.Header != nil { - resp.MetaData = metadata.ParseFromHeaders(resp.HttpResponse.Header) - } - } - return } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/metadata_set.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/metadata_set.go index 3a23d90e780f..55bf1d4bedfc 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/metadata_set.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/metadata_set.go @@ -12,7 +12,7 @@ import ( ) type SetMetaDataResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } type SetMetaDataInput struct { @@ -20,18 +20,21 @@ type SetMetaDataInput struct { } // SetMetaData sets the MetaData on the specified Storage Share -func (c Client) SetMetaData(ctx context.Context, shareName string, input SetMetaDataInput) (resp SetMetaDataResponse, err error) { +func (c Client) SetMetaData(ctx context.Context, shareName string, input SetMetaDataInput) (result SetMetaDataResponse, err error) { if shareName == "" { - return resp, fmt.Errorf("`shareName` cannot be an empty string") + err = fmt.Errorf("`shareName` cannot be an empty string") + return } if strings.ToLower(shareName) != shareName { - return resp, fmt.Errorf("`shareName` must be a lower-cased string") + err = fmt.Errorf("`shareName` must be a lower-cased string") + return } - if err := metadata.Validate(input.MetaData); err != nil { - return resp, fmt.Errorf("`metadata` is not valid: %v", err) + if err = metadata.Validate(input.MetaData); err != nil { + err = fmt.Errorf("`metadata` is not valid: %+v", err) + return } opts := client.RequestOptions{ @@ -52,7 +55,11 @@ func (c Client) SetMetaData(ctx context.Context, shareName string, input SetMeta return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/properties_get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/properties_get.go index 763584ef648b..57a2a7fda758 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/properties_get.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/properties_get.go @@ -3,16 +3,16 @@ package shares import ( "context" "fmt" + "github.com/tombuildsstuff/giovanni/storage/internal/metadata" "net/http" "strconv" "strings" "github.com/hashicorp/go-azure-sdk/sdk/client" - "github.com/tombuildsstuff/giovanni/storage/internal/metadata" ) type GetPropertiesResult struct { - HttpResponse *client.Response + HttpResponse *http.Response MetaData map[string]string QuotaInGB int @@ -21,13 +21,15 @@ type GetPropertiesResult struct { } // GetProperties returns the properties about the specified Storage Share -func (c Client) GetProperties(ctx context.Context, shareName string) (resp GetPropertiesResult, err error) { +func (c Client) GetProperties(ctx context.Context, shareName string) (result GetPropertiesResult, err error) { if shareName == "" { - return resp, fmt.Errorf("`shareName` cannot be an empty string") + err = fmt.Errorf("`shareName` cannot be an empty string") + return } if strings.ToLower(shareName) != shareName { - return resp, fmt.Errorf("`shareName` must be a lower-cased string") + err = fmt.Errorf("`shareName` must be a lower-cased string") + return } opts := client.RequestOptions{ @@ -46,37 +48,40 @@ func (c Client) GetProperties(ctx context.Context, shareName string) (resp GetPr return } - resp.HttpResponse, err = req.Execute(ctx) - if err != nil { - err = fmt.Errorf("executing request: %+v", err) - return - } + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response - if resp.HttpResponse != nil { - if resp.HttpResponse.Header != nil { - resp.MetaData = metadata.ParseFromHeaders(resp.HttpResponse.Header) + if resp.Header != nil { + result.MetaData = metadata.ParseFromHeaders(resp.Header) - quotaRaw := resp.HttpResponse.Header.Get("x-ms-share-quota") + quotaRaw := resp.Header.Get("x-ms-share-quota") if quotaRaw != "" { quota, e := strconv.Atoi(quotaRaw) if e != nil { - return resp, fmt.Errorf("error converting %q to an integer: %s", quotaRaw, err) + err = fmt.Errorf("error converting %q to an integer: %s", quotaRaw, err) + return } - resp.QuotaInGB = quota + result.QuotaInGB = quota } protocol := SMB - if protocolRaw := resp.HttpResponse.Header.Get("x-ms-enabled-protocols"); protocolRaw != "" { + if protocolRaw := resp.Header.Get("x-ms-enabled-protocols"); protocolRaw != "" { protocol = ShareProtocol(protocolRaw) } - if accessTierRaw := resp.HttpResponse.Header.Get("x-ms-access-tier"); accessTierRaw != "" { + if accessTierRaw := resp.Header.Get("x-ms-access-tier"); accessTierRaw != "" { tier := AccessTier(accessTierRaw) - resp.AccessTier = &tier + result.AccessTier = &tier } - resp.EnabledProtocol = protocol + result.EnabledProtocol = protocol } } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } return } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/properties_set.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/properties_set.go index ef3854af6de9..f80df4fdce1c 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/properties_set.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/properties_set.go @@ -17,22 +17,22 @@ type ShareProperties struct { } type SetPropertiesResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } // SetProperties lets you update the Quota for the specified Storage Share -func (c Client) SetProperties(ctx context.Context, shareName string, properties ShareProperties) (resp SetPropertiesResponse, err error) { +func (c Client) SetProperties(ctx context.Context, shareName string, properties ShareProperties) (result SetPropertiesResponse, err error) { if shareName == "" { - return resp, fmt.Errorf("`shareName` cannot be an empty string") + return result, fmt.Errorf("`shareName` cannot be an empty string") } if strings.ToLower(shareName) != shareName { - return resp, fmt.Errorf("`shareName` must be a lower-cased string") + return result, fmt.Errorf("`shareName` must be a lower-cased string") } if newQuotaGB := properties.QuotaInGb; newQuotaGB != nil && (*newQuotaGB <= 0 || *newQuotaGB > 102400) { - return resp, fmt.Errorf("`newQuotaGB` must be greater than 0, and less than/equal to 100TB (102400 GB)") + return result, fmt.Errorf("`newQuotaGB` must be greater than 0, and less than/equal to 100TB (102400 GB)") } opts := client.RequestOptions{ @@ -53,7 +53,11 @@ func (c Client) SetProperties(ctx context.Context, shareName string, properties return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/snapshot_create.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/snapshot_create.go index 8ba7a07c7b4a..d4dff0328043 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/snapshot_create.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/snapshot_create.go @@ -16,7 +16,7 @@ type CreateSnapshotInput struct { } type CreateSnapshotResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response // This header is a DateTime value that uniquely identifies the share snapshot. // The value of this header may be used in subsequent requests to access the share snapshot. @@ -27,18 +27,21 @@ type CreateSnapshotResponse struct { // CreateSnapshot creates a read-only snapshot of the share // A share can support creation of 200 share snapshots. Attempting to create more than 200 share snapshots fails with 409 (Conflict). // Attempting to create a share snapshot while a previous Snapshot Share operation is in progress fails with 409 (Conflict). -func (c Client) CreateSnapshot(ctx context.Context, shareName string, input CreateSnapshotInput) (resp CreateSnapshotResponse, err error) { +func (c Client) CreateSnapshot(ctx context.Context, shareName string, input CreateSnapshotInput) (result CreateSnapshotResponse, err error) { if shareName == "" { - return resp, fmt.Errorf("`shareName` cannot be an empty string") + err = fmt.Errorf("`shareName` cannot be an empty string") + return } if strings.ToLower(shareName) != shareName { - return resp, fmt.Errorf("`shareName` must be a lower-cased string") + err = fmt.Errorf("`shareName` must be a lower-cased string") + return } if err = metadata.Validate(input.MetaData); err != nil { - return resp, fmt.Errorf("`input.MetaData` is not valid: %v", err) + err = fmt.Errorf("`input.MetaData` is not valid: %+v", err) + return } opts := client.RequestOptions{ @@ -59,17 +62,20 @@ func (c Client) CreateSnapshot(ctx context.Context, shareName string, input Crea return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if resp.Header != nil { + result.SnapshotDateTime = resp.Header.Get("x-ms-snapshot") + } + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return } - if resp.HttpResponse != nil { - if resp.HttpResponse.Header != nil { - resp.SnapshotDateTime = resp.HttpResponse.Header.Get("x-ms-snapshot") - } - } return } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/snapshot_delete.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/snapshot_delete.go index bf3ccd6719a6..64dd532068a0 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/snapshot_delete.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/snapshot_delete.go @@ -11,22 +11,22 @@ import ( ) type DeleteSnapshotResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } // DeleteSnapshot deletes the specified Snapshot of a Storage Share -func (c Client) DeleteSnapshot(ctx context.Context, accountName, shareName string, shareSnapshot string) (resp DeleteSnapshotResponse, err error) { +func (c Client) DeleteSnapshot(ctx context.Context, accountName, shareName string, shareSnapshot string) (result DeleteSnapshotResponse, err error) { if shareName == "" { - return resp, fmt.Errorf("`shareName` cannot be an empty string") + return result, fmt.Errorf("`shareName` cannot be an empty string") } if strings.ToLower(shareName) != shareName { - return resp, fmt.Errorf("`shareName` must be a lower-cased string") + return result, fmt.Errorf("`shareName` must be a lower-cased string") } if shareSnapshot == "" { - return resp, fmt.Errorf("`shareSnapshot` cannot be an empty string") + return result, fmt.Errorf("`shareSnapshot` cannot be an empty string") } opts := client.RequestOptions{ @@ -47,7 +47,11 @@ func (c Client) DeleteSnapshot(ctx context.Context, accountName, shareName strin return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/snapshot_get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/snapshot_get.go index f4a12e9f0cdc..b93d9f613575 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/snapshot_get.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/snapshot_get.go @@ -3,16 +3,16 @@ package shares import ( "context" "fmt" + "github.com/tombuildsstuff/giovanni/storage/internal/metadata" "net/http" "strings" "github.com/hashicorp/go-azure-sdk/sdk/client" "github.com/hashicorp/go-azure-sdk/sdk/odata" - "github.com/tombuildsstuff/giovanni/storage/internal/metadata" ) type GetSnapshotPropertiesResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response MetaData map[string]string } @@ -22,17 +22,20 @@ type GetSnapshotPropertiesInput struct { } // GetSnapshot gets information about the specified Snapshot of the specified Storage Share -func (c Client) GetSnapshot(ctx context.Context, shareName string, input GetSnapshotPropertiesInput) (resp GetSnapshotPropertiesResponse, err error) { +func (c Client) GetSnapshot(ctx context.Context, shareName string, input GetSnapshotPropertiesInput) (result GetSnapshotPropertiesResponse, err error) { if shareName == "" { - return resp, fmt.Errorf("`shareName` cannot be an empty string") + err = fmt.Errorf("`shareName` cannot be an empty string") + return } if strings.ToLower(shareName) != shareName { - return resp, fmt.Errorf("`shareName` must be a lower-cased string") + err = fmt.Errorf("`shareName` must be a lower-cased string") + return } if input.snapshotShare == "" { - return resp, fmt.Errorf("`snapshotShare` cannot be an empty string") + err = fmt.Errorf("`snapshotShare` cannot be an empty string") + return } opts := client.RequestOptions{ @@ -53,18 +56,20 @@ func (c Client) GetSnapshot(ctx context.Context, shareName string, input GetSnap return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if resp.Header != nil { + result.MetaData = metadata.ParseFromHeaders(resp.Header) + } + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return } - if resp.HttpResponse != nil { - if resp.HttpResponse.Header != nil { - resp.MetaData = metadata.ParseFromHeaders(resp.HttpResponse.Header) - } - } - return } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/stats.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/stats.go index 23e48afe4043..d375d837ed7e 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/stats.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/stats.go @@ -11,7 +11,7 @@ import ( ) type GetStatsResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response // The approximate size of the data stored on the share. // Note that this value may not include all recently created or recently resized files. @@ -19,13 +19,15 @@ type GetStatsResponse struct { } // GetStats returns information about the specified Storage Share -func (c Client) GetStats(ctx context.Context, shareName string) (resp GetStatsResponse, err error) { +func (c Client) GetStats(ctx context.Context, shareName string) (result GetStatsResponse, err error) { if shareName == "" { - return resp, fmt.Errorf("`shareName` cannot be an empty string") + err = fmt.Errorf("`shareName` cannot be an empty string") + return } if strings.ToLower(shareName) != shareName { - return resp, fmt.Errorf("`shareName` must be a lower-cased string") + err = fmt.Errorf("`shareName` must be a lower-cased string") + return } opts := client.RequestOptions{ @@ -44,18 +46,22 @@ func (c Client) GetStats(ctx context.Context, shareName string) (resp GetStatsRe return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + err = resp.Unmarshal(&result) + if err != nil { + err = fmt.Errorf("unmarshalling response: %+v", err) + return + } + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return } - if resp.HttpResponse != nil { - err = resp.HttpResponse.Unmarshal(&resp) - if err != nil { - return resp, fmt.Errorf("unmarshalling response: %v", err) - } - } return } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/create.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/create.go index d156052ca70d..f548088ce288 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/create.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/create.go @@ -16,22 +16,22 @@ type CreateInput struct { } type CreateResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } // Create creates the specified Queue within the specified Storage Account -func (c Client) Create(ctx context.Context, queueName string, input CreateInput) (resp CreateResponse, err error) { +func (c Client) Create(ctx context.Context, queueName string, input CreateInput) (result CreateResponse, err error) { if queueName == "" { - return resp, fmt.Errorf("`queueName` cannot be an empty string") + return result, fmt.Errorf("`queueName` cannot be an empty string") } if strings.ToLower(queueName) != queueName { - return resp, fmt.Errorf("`queueName` must be a lower-cased string") + return result, fmt.Errorf("`queueName` must be a lower-cased string") } if err := metadata.Validate(input.MetaData); err != nil { - return resp, fmt.Errorf("`metadata` is not valid: %s", err) + return result, fmt.Errorf("`metadata` is not valid: %s", err) } opts := client.RequestOptions{ @@ -52,7 +52,11 @@ func (c Client) Create(ctx context.Context, queueName string, input CreateInput) return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/delete.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/delete.go index 39d5d64fa059..e8d7babb12fe 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/delete.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/delete.go @@ -10,18 +10,18 @@ import ( ) type DeleteResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } // Delete deletes the specified Queue within the specified Storage Account -func (c Client) Delete(ctx context.Context, queueName string) (resp DeleteResponse, err error) { +func (c Client) Delete(ctx context.Context, queueName string) (result DeleteResponse, err error) { if queueName == "" { - return resp, fmt.Errorf("`queueName` cannot be an empty string") + return result, fmt.Errorf("`queueName` cannot be an empty string") } if strings.ToLower(queueName) != queueName { - return resp, fmt.Errorf("`queueName` must be a lower-cased string") + return result, fmt.Errorf("`queueName` must be a lower-cased string") } opts := client.RequestOptions{ @@ -40,7 +40,11 @@ func (c Client) Delete(ctx context.Context, queueName string) (resp DeleteRespon return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/metadata_get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/metadata_get.go index 14c32d64d0f5..c8a259f451ba 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/metadata_get.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/metadata_get.go @@ -12,20 +12,20 @@ import ( ) type GetMetaDataResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response MetaData map[string]string } // GetMetaData returns the metadata for this Queue -func (c Client) GetMetaData(ctx context.Context, queueName string) (resp GetMetaDataResponse, err error) { +func (c Client) GetMetaData(ctx context.Context, queueName string) (result GetMetaDataResponse, err error) { if queueName == "" { - return resp, fmt.Errorf("`queueName` cannot be an empty string") + return result, fmt.Errorf("`queueName` cannot be an empty string") } if strings.ToLower(queueName) != queueName { - return resp, fmt.Errorf("`queueName` must be a lower-cased string") + return result, fmt.Errorf("`queueName` must be a lower-cased string") } opts := client.RequestOptions{ @@ -44,15 +44,23 @@ func (c Client) GetMetaData(ctx context.Context, queueName string) (resp GetMeta return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if resp.Header != nil { + result.MetaData = metadata.ParseFromHeaders(resp.Header) + } + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return } - if resp.HttpResponse != nil { - if resp.HttpResponse.Header != nil { - resp.MetaData = metadata.ParseFromHeaders(resp.HttpResponse.Header) + if result.HttpResponse != nil { + if result.HttpResponse.Header != nil { + result.MetaData = metadata.ParseFromHeaders(result.HttpResponse.Header) } } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/metadata_set.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/metadata_set.go index ea8eac3192da..6ab770de1f52 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/metadata_set.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/metadata_set.go @@ -12,7 +12,7 @@ import ( ) type SetMetaDataResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } type SetMetaDataInput struct { @@ -20,18 +20,18 @@ type SetMetaDataInput struct { } // SetMetaData returns the metadata for this Queue -func (c Client) SetMetaData(ctx context.Context, queueName string, input SetMetaDataInput) (resp SetMetaDataResponse, err error) { +func (c Client) SetMetaData(ctx context.Context, queueName string, input SetMetaDataInput) (result SetMetaDataResponse, err error) { if queueName == "" { - return resp, fmt.Errorf("`queueName` cannot be an empty string") + return result, fmt.Errorf("`queueName` cannot be an empty string") } if strings.ToLower(queueName) != queueName { - return resp, fmt.Errorf("`queueName` must be a lower-cased string") + return result, fmt.Errorf("`queueName` must be a lower-cased string") } if err := metadata.Validate(input.MetaData); err != nil { - return resp, fmt.Errorf("`metadata` is not valid: %v", err) + return result, fmt.Errorf("`metadata` is not valid: %+v", err) } opts := client.RequestOptions{ @@ -52,7 +52,11 @@ func (c Client) SetMetaData(ctx context.Context, queueName string, input SetMeta return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/models.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/models.go index 2195244fa44b..fbbbce9634c4 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/models.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/models.go @@ -36,7 +36,7 @@ type Cors struct { type CorsRule struct { AllowedOrigins string `xml:"AllowedOrigins"` AllowedMethods string `xml:"AllowedMethods"` - AllowedHeaders string `xml:"AllowedHeaders` + AllowedHeaders string `xml:"AllowedHeaders"` ExposedHeaders string `xml:"ExposedHeaders"` MaxAgeInSeconds int `xml:"MaxAgeInSeconds"` } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/properties_get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/properties_get.go index b2ea774e5534..0647f26d1b8f 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/properties_get.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/properties_get.go @@ -11,11 +11,11 @@ import ( type GetStorageServicePropertiesResponse struct { StorageServiceProperties - HttpResponse *client.Response + HttpResponse *http.Response } // GetServiceProperties gets the properties for this queue -func (c Client) GetServiceProperties(ctx context.Context) (resp GetStorageServicePropertiesResponse, err error) { +func (c Client) GetServiceProperties(ctx context.Context) (result GetStorageServicePropertiesResponse, err error) { opts := client.RequestOptions{ ContentType: "application/xml; charset=utf-8", @@ -33,18 +33,21 @@ func (c Client) GetServiceProperties(ctx context.Context) (resp GetStorageServic return } - resp.HttpResponse, err = req.Execute(ctx) - if err != nil { - err = fmt.Errorf("executing request: %+v", err) - return - } + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response - if resp.HttpResponse != nil { - err = resp.HttpResponse.Unmarshal(&resp) + err = resp.Unmarshal(&result) if err != nil { - return resp, fmt.Errorf("unmarshalling respnse: %v", err) + err = fmt.Errorf("unmarshalling response: %+v", err) + return } } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } return } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/properties_set.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/properties_set.go index 744bd9767ed1..d80b6728b398 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/properties_set.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/properties_set.go @@ -14,7 +14,7 @@ import ( ) type SetStorageServicePropertiesResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } type SetStorageServicePropertiesInput struct { @@ -22,7 +22,7 @@ type SetStorageServicePropertiesInput struct { } // SetServiceProperties sets the properties for this queue -func (c Client) SetServiceProperties(ctx context.Context, input SetStorageServicePropertiesInput) (resp SetStorageServicePropertiesResponse, err error) { +func (c Client) SetServiceProperties(ctx context.Context, input SetStorageServicePropertiesInput) (result SetStorageServicePropertiesResponse, err error) { opts := client.RequestOptions{ ContentType: "application/xml; charset=utf-8", @@ -42,14 +42,18 @@ func (c Client) SetServiceProperties(ctx context.Context, input SetStorageServic marshalledProps, err := xml.Marshal(&input.Properties) if err != nil { - return resp, fmt.Errorf("marshalling request: %v", err) + return result, fmt.Errorf("marshalling request: %+v", err) } body := xml.Header + string(marshalledProps) req.Body = io.NopCloser(bytes.NewReader([]byte(body))) req.ContentLength = int64(len(body)) req.Header.Set("Content-Length", strconv.Itoa(len(body))) - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/delete.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/delete.go index 05d09b3ce32e..61e7c712ac5e 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/delete.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/delete.go @@ -20,22 +20,22 @@ type DeleteEntityInput struct { } type DeleteEntityResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } // Delete deletes an existing entity in a table. -func (c Client) Delete(ctx context.Context, tableName string, input DeleteEntityInput) (resp DeleteEntityResponse, err error) { +func (c Client) Delete(ctx context.Context, tableName string, input DeleteEntityInput) (result DeleteEntityResponse, err error) { if tableName == "" { - return resp, fmt.Errorf("`tableName` cannot be an empty string") + return result, fmt.Errorf("`tableName` cannot be an empty string") } if input.PartitionKey == "" { - return resp, fmt.Errorf("`input.PartitionKey` cannot be an empty string") + return result, fmt.Errorf("`input.PartitionKey` cannot be an empty string") } if input.RowKey == "" { - return resp, fmt.Errorf("`input.RowKey` cannot be an empty string") + return result, fmt.Errorf("`input.RowKey` cannot be an empty string") } opts := client.RequestOptions{ @@ -54,7 +54,11 @@ func (c Client) Delete(ctx context.Context, tableName string, input DeleteEntity return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/get.go index 14cd5ad38d04..daf428acdffa 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/get.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/get.go @@ -18,23 +18,23 @@ type GetEntityInput struct { } type GetEntityResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response Entity map[string]interface{} } // Get queries entities in a table and includes the $filter and $select options. -func (c Client) Get(ctx context.Context, tableName string, input GetEntityInput) (resp GetEntityResponse, err error) { +func (c Client) Get(ctx context.Context, tableName string, input GetEntityInput) (result GetEntityResponse, err error) { if tableName == "" { - return resp, fmt.Errorf("`tableName` cannot be an empty string") + return result, fmt.Errorf("`tableName` cannot be an empty string") } if input.PartitionKey == "" { - return resp, fmt.Errorf("`input.PartitionKey` cannot be an empty string") + return result, fmt.Errorf("`input.PartitionKey` cannot be an empty string") } if input.RowKey == "" { - return resp, fmt.Errorf("`input.RowKey` cannot be an empty string") + return result, fmt.Errorf("`input.RowKey` cannot be an empty string") } opts := client.RequestOptions{ @@ -54,20 +54,22 @@ func (c Client) Get(ctx context.Context, tableName string, input GetEntityInput) return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + err = resp.Unmarshal(&result.Entity) + if err != nil { + err = fmt.Errorf("unmarshalling response: %+v", err) + return + } + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return } - if resp.HttpResponse != nil { - if resp.HttpResponse.Body != nil { - err = resp.HttpResponse.Unmarshal(&resp.Entity) - if err != nil { - return resp, fmt.Errorf("unmarshalling response: %+v", err) - } - } - } return } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/insert.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/insert.go index 315b7ce5b653..1996ba8b9cef 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/insert.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/insert.go @@ -28,21 +28,21 @@ type InsertEntityInput struct { } type InsertResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } // Insert inserts a new entity into a table. -func (c Client) Insert(ctx context.Context, tableName string, input InsertEntityInput) (resp InsertResponse, err error) { +func (c Client) Insert(ctx context.Context, tableName string, input InsertEntityInput) (result InsertResponse, err error) { if tableName == "" { - return resp, fmt.Errorf("`tableName` cannot be an empty string") + return result, fmt.Errorf("`tableName` cannot be an empty string") } if input.PartitionKey == "" { - return resp, fmt.Errorf("`input.PartitionKey` cannot be an empty string") + return result, fmt.Errorf("`input.PartitionKey` cannot be an empty string") } if input.RowKey == "" { - return resp, fmt.Errorf("`input.RowKey` cannot be an empty string") + return result, fmt.Errorf("`input.RowKey` cannot be an empty string") } opts := client.RequestOptions{ @@ -68,10 +68,14 @@ func (c Client) Insert(ctx context.Context, tableName string, input InsertEntity err = req.Marshal(&input.Entity) if err != nil { - return resp, fmt.Errorf("marshalling request: %v", err) + return result, fmt.Errorf("marshalling request: %+v", err) } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/insert_or_merge.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/insert_or_merge.go index 27cae93239bf..8ec8191f6ea5 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/insert_or_merge.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/insert_or_merge.go @@ -25,22 +25,22 @@ type InsertOrMergeEntityInput struct { } type InsertOrMergeResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } // InsertOrMerge updates an existing entity or inserts a new entity if it does not exist in the table. // Because this operation can insert or update an entity, it is also known as an upsert operation. -func (c Client) InsertOrMerge(ctx context.Context, tableName string, input InsertOrMergeEntityInput) (resp InsertOrMergeResponse, err error) { +func (c Client) InsertOrMerge(ctx context.Context, tableName string, input InsertOrMergeEntityInput) (result InsertOrMergeResponse, err error) { if tableName == "" { - return resp, fmt.Errorf("`tableName` cannot be an empty string") + return result, fmt.Errorf("`tableName` cannot be an empty string") } if input.PartitionKey == "" { - return resp, fmt.Errorf("`input.PartitionKey` cannot be an empty string") + return result, fmt.Errorf("`input.PartitionKey` cannot be an empty string") } if input.RowKey == "" { - return resp, fmt.Errorf("`input.RowKey` cannot be an empty string") + return result, fmt.Errorf("`input.RowKey` cannot be an empty string") } opts := client.RequestOptions{ @@ -64,10 +64,14 @@ func (c Client) InsertOrMerge(ctx context.Context, tableName string, input Inser err = req.Marshal(&input.Entity) if err != nil { - return resp, fmt.Errorf("marshalling request: %v", err) + return result, fmt.Errorf("marshalling request: %+v", err) } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/insert_or_replace.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/insert_or_replace.go index 6f97eb624b7d..269437c06cae 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/insert_or_replace.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/insert_or_replace.go @@ -25,22 +25,22 @@ type InsertOrReplaceEntityInput struct { } type InsertOrReplaceResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } // InsertOrReplace replaces an existing entity or inserts a new entity if it does not exist in the table. // Because this operation can insert or update an entity, it is also known as an upsert operation. -func (c Client) InsertOrReplace(ctx context.Context, tableName string, input InsertOrReplaceEntityInput) (resp InsertOrReplaceResponse, err error) { +func (c Client) InsertOrReplace(ctx context.Context, tableName string, input InsertOrReplaceEntityInput) (result InsertOrReplaceResponse, err error) { if tableName == "" { - return resp, fmt.Errorf("`tableName` cannot be an empty string") + return result, fmt.Errorf("`tableName` cannot be an empty string") } if input.PartitionKey == "" { - return resp, fmt.Errorf("`input.PartitionKey` cannot be an empty string") + return result, fmt.Errorf("`input.PartitionKey` cannot be an empty string") } if input.RowKey == "" { - return resp, fmt.Errorf("`input.RowKey` cannot be an empty string") + return result, fmt.Errorf("`input.RowKey` cannot be an empty string") } opts := client.RequestOptions{ @@ -64,10 +64,14 @@ func (c Client) InsertOrReplace(ctx context.Context, tableName string, input Ins err = req.Marshal(&input.Entity) if err != nil { - return resp, fmt.Errorf("marshalling request: %v", err) + return result, fmt.Errorf("marshalling request: %+v", err) } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/query.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/query.go index 9137401377df..57b411a55bf6 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/query.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/query.go @@ -35,7 +35,7 @@ type QueryEntitiesInput struct { } type QueryEntitiesResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response NextPartitionKey string NextRowKey string @@ -45,9 +45,9 @@ type QueryEntitiesResponse struct { } // Query queries entities in a table and includes the $filter and $select options. -func (c Client) Query(ctx context.Context, tableName string, input QueryEntitiesInput) (resp QueryEntitiesResponse, err error) { +func (c Client) Query(ctx context.Context, tableName string, input QueryEntitiesInput) (result QueryEntitiesResponse, err error) { if tableName == "" { - return resp, fmt.Errorf("`tableName` cannot be an empty string") + return result, fmt.Errorf("`tableName` cannot be an empty string") } additionalParameters := make([]string, 0) @@ -82,21 +82,22 @@ func (c Client) Query(ctx context.Context, tableName string, input QueryEntities return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + err = resp.Unmarshal(&result) + if err != nil { + err = fmt.Errorf("unmarshalling response: %+v", err) + return + } + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return } - if resp.HttpResponse != nil { - if resp.HttpResponse.Body != nil { - err = resp.HttpResponse.Unmarshal(&resp) - if err != nil { - return resp, fmt.Errorf("unmarshalling response: %v", err) - } - } - } - return } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/acl_get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/acl_get.go index d927d38f9c90..3f2f2a18692f 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/acl_get.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/acl_get.go @@ -10,16 +10,17 @@ import ( ) type GetACLResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response SignedIdentifiers []SignedIdentifier `xml:"SignedIdentifier"` } // GetACL returns the Access Control List for the specified Table -func (c Client) GetACL(ctx context.Context, tableName string) (resp GetACLResponse, err error) { +func (c Client) GetACL(ctx context.Context, tableName string) (result GetACLResponse, err error) { if tableName == "" { - return resp, fmt.Errorf("`tableName` cannot be an empty string") + err = fmt.Errorf("`tableName` cannot be an empty string") + return } opts := client.RequestOptions{ @@ -38,21 +39,22 @@ func (c Client) GetACL(ctx context.Context, tableName string) (resp GetACLRespon return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + err = resp.Unmarshal(&result) + if err != nil { + err = fmt.Errorf("unmarshalling response: %+v", err) + return + } + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return } - if resp.HttpResponse != nil { - if resp.HttpResponse.Body != nil { - err = resp.HttpResponse.Unmarshal(&resp) - if err != nil { - return resp, fmt.Errorf("unmarshalling response body: %v", err) - } - } - } - return } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/acl_set.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/acl_set.go index 9ff4ad0e0a1e..9749bd062c5f 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/acl_set.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/acl_set.go @@ -17,13 +17,14 @@ type setAcl struct { } type SetACLResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } // SetACL sets the specified Access Control List for the specified Table -func (c Client) SetACL(ctx context.Context, tableName string, acls []SignedIdentifier) (resp SetACLResponse, err error) { +func (c Client) SetACL(ctx context.Context, tableName string, acls []SignedIdentifier) (result SetACLResponse, err error) { if tableName == "" { - return resp, fmt.Errorf("`tableName` cannot be an empty string") + err = fmt.Errorf("`tableName` cannot be an empty string") + return } opts := client.RequestOptions{ @@ -44,10 +45,15 @@ func (c Client) SetACL(ctx context.Context, tableName string, acls []SignedIdent err = req.Marshal(setAcl{SignedIdentifiers: acls}) if err != nil { - return resp, fmt.Errorf("marshalling request: %+v", err) + err = fmt.Errorf("marshalling request: %+v", err) + return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/create.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/create.go index feeebe40052f..6adfd5ab5e36 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/create.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/create.go @@ -14,13 +14,14 @@ type createTableRequest struct { } type CreateTableResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } // Create creates a new table in the storage account. -func (c Client) Create(ctx context.Context, tableName string) (resp CreateTableResponse, err error) { +func (c Client) Create(ctx context.Context, tableName string) (result CreateTableResponse, err error) { if tableName == "" { - return resp, fmt.Errorf("`tableName` cannot be an empty string") + err = fmt.Errorf("`tableName` cannot be an empty string") + return } opts := client.RequestOptions{ @@ -41,10 +42,14 @@ func (c Client) Create(ctx context.Context, tableName string) (resp CreateTableR err = req.Marshal(&createTableRequest{TableName: tableName}) if err != nil { - return resp, fmt.Errorf("marshalling request") + return result, fmt.Errorf("marshalling request") } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/delete.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/delete.go index 3a2817f48282..b1fab65b30c0 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/delete.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/delete.go @@ -10,13 +10,14 @@ import ( ) type DeleteTableResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } // Delete deletes the specified table and any data it contains. -func (c Client) Delete(ctx context.Context, tableName string) (resp DeleteTableResponse, err error) { +func (c Client) Delete(ctx context.Context, tableName string) (result DeleteTableResponse, err error) { if tableName == "" { - return resp, fmt.Errorf("`tableName` cannot be an empty string") + err = fmt.Errorf("`tableName` cannot be an empty string") + return } opts := client.RequestOptions{ @@ -35,7 +36,11 @@ func (c Client) Delete(ctx context.Context, tableName string) (resp DeleteTableR return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/exists.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/exists.go index 1497695cf03f..efd922e2a8ca 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/exists.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/exists.go @@ -10,13 +10,14 @@ import ( ) type TableExistsResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response } // Exists checks that the specified table exists -func (c Client) Exists(ctx context.Context, tableName string) (resp TableExistsResponse, err error) { +func (c Client) Exists(ctx context.Context, tableName string) (result TableExistsResponse, err error) { if tableName == "" { - return resp, fmt.Errorf("`tableName` cannot be an empty string") + err = fmt.Errorf("`tableName` cannot be an empty string") + return } opts := client.RequestOptions{ @@ -37,10 +38,15 @@ func (c Client) Exists(ctx context.Context, tableName string) (resp TableExistsR err = req.Marshal(&createTableRequest{TableName: tableName}) if err != nil { - return resp, fmt.Errorf("marshalling request") + err = fmt.Errorf("marshalling request") + return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/query.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/query.go index 9a15de8d0fa7..4cc07ead352e 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/query.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/query.go @@ -10,7 +10,7 @@ import ( ) type GetResponse struct { - HttpResponse *client.Response + HttpResponse *http.Response MetaData string `json:"odata.metadata,omitempty"` Tables []GetResultItem `json:"value"` @@ -21,7 +21,7 @@ type QueryInput struct { } // Query returns a list of tables under the specified account. -func (c Client) Query(ctx context.Context, input QueryInput) (resp GetResponse, err error) { +func (c Client) Query(ctx context.Context, input QueryInput) (result GetResponse, err error) { opts := client.RequestOptions{ ExpectedStatusCodes: []int{ @@ -40,21 +40,22 @@ func (c Client) Query(ctx context.Context, input QueryInput) (resp GetResponse, return } - resp.HttpResponse, err = req.Execute(ctx) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + err = resp.Unmarshal(&result) + if err != nil { + err = fmt.Errorf("unmarshalling response: %+v", err) + return + } + } if err != nil { err = fmt.Errorf("executing request: %+v", err) return } - if resp.HttpResponse != nil { - if resp.HttpResponse.Body != nil { - err = resp.HttpResponse.Unmarshal(&resp) - if err != nil { - return resp, fmt.Errorf("unmarshalling response: %v", err) - } - } - } - return } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/internal/metadata/parse.go b/vendor/github.com/tombuildsstuff/giovanni/storage/internal/metadata/parse.go index 038b12c4f5e2..5f613ab7d15b 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/internal/metadata/parse.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/internal/metadata/parse.go @@ -5,7 +5,7 @@ import ( "strings" ) -// ParseFromHeaders parses the meta data from the headers +// ParseFromHeaders parses the metadata from the headers func ParseFromHeaders(headers http.Header) map[string]string { metaData := make(map[string]string, 0) prefix := "x-ms-meta-" diff --git a/vendor/modules.txt b/vendor/modules.txt index 84c572ba2335..96ca655c7c55 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1236,7 +1236,7 @@ github.com/rickb777/plural # github.com/sergi/go-diff v1.2.0 ## explicit; go 1.12 github.com/sergi/go-diff/diffmatchpatch -# github.com/tombuildsstuff/giovanni v0.23.0 +# github.com/tombuildsstuff/giovanni v0.23.0 => /Users/tom/git/tombuildsstuff/giovanni ## explicit; go 1.21 github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/accounts github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs @@ -1488,3 +1488,4 @@ gopkg.in/yaml.v3 software.sslmate.com/src/go-pkcs12 software.sslmate.com/src/go-pkcs12/internal/rc2 # github.com/hashicorp/go-azure-sdk/sdk => /Users/tom/git/hashicorp/go-azure-sdk/sdk +# github.com/tombuildsstuff/giovanni => /Users/tom/git/tombuildsstuff/giovanni