From e45c594e06436ec29cbdc97e86d655d4173caa41 Mon Sep 17 00:00:00 2001 From: Henry McConville Date: Tue, 27 Jul 2021 06:41:59 +0100 Subject: [PATCH] Bugfix: `azurerm_data_factory_dataset_binary` - Make blob path/filename optional (#12676) --- .../data_factory_dataset_binary_resource.go | 4 +- ...ta_factory_dataset_binary_resource_test.go | 67 +++++++++++++++++++ .../data_factory_dataset_binary.html.markdown | 6 +- 3 files changed, 72 insertions(+), 5 deletions(-) diff --git a/azurerm/internal/services/datafactory/data_factory_dataset_binary_resource.go b/azurerm/internal/services/datafactory/data_factory_dataset_binary_resource.go index 16de9701ec6b..e7bf5a959dde 100644 --- a/azurerm/internal/services/datafactory/data_factory_dataset_binary_resource.go +++ b/azurerm/internal/services/datafactory/data_factory_dataset_binary_resource.go @@ -122,12 +122,12 @@ func resourceDataFactoryDatasetBinary() *pluginsdk.Resource { }, "path": { Type: pluginsdk.TypeString, - Required: true, + Optional: true, ValidateFunc: validation.StringIsNotEmpty, }, "filename": { Type: pluginsdk.TypeString, - Required: true, + Optional: true, ValidateFunc: validation.StringIsNotEmpty, }, }, diff --git a/azurerm/internal/services/datafactory/data_factory_dataset_binary_resource_test.go b/azurerm/internal/services/datafactory/data_factory_dataset_binary_resource_test.go index b7a49693f7f1..bd99bee7de22 100644 --- a/azurerm/internal/services/datafactory/data_factory_dataset_binary_resource_test.go +++ b/azurerm/internal/services/datafactory/data_factory_dataset_binary_resource_test.go @@ -31,6 +31,21 @@ func TestAccDataFactoryDatasetBinary_blob(t *testing.T) { }) } +func TestAccDataFactoryDatasetBinary_blob_with_filepath(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_data_factory_dataset_binary", "test") + r := DatasetBinaryResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.blob_with_filepath(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + func TestAccDataFactoryDatasetBinary_http(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_data_factory_dataset_binary", "test") r := DatasetBinaryResource{} @@ -125,6 +140,58 @@ resource "azurerm_data_factory" "test" { } +resource "azurerm_data_factory_linked_service_azure_blob_storage" "test" { + name = "acctestlsblob%d" + resource_group_name = azurerm_resource_group.test.name + data_factory_name = azurerm_data_factory.test.name + connection_string = azurerm_storage_account.test.primary_connection_string +} + +resource "azurerm_data_factory_dataset_binary" "test" { + name = "acctestds%d" + resource_group_name = azurerm_resource_group.test.name + data_factory_name = azurerm_data_factory.test.name + linked_service_name = azurerm_data_factory_linked_service_azure_blob_storage.test.name + + azure_blob_storage_location { + container = azurerm_storage_container.test.name + } +} +`, data.RandomInteger, data.Locations.Primary, data.RandomString, data.RandomInteger, data.RandomInteger, data.RandomInteger) +} + +func (DatasetBinaryResource) blob_with_filepath(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-df-%d" + location = "%s" +} + +resource "azurerm_storage_account" "test" { + name = "acctestdf%s" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + account_tier = "Standard" + account_replication_type = "GRS" +} + +resource "azurerm_storage_container" "test" { + name = "content" + storage_account_name = azurerm_storage_account.test.name + container_access_type = "private" +} + +resource "azurerm_data_factory" "test" { + name = "acctestdf%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name +} + + resource "azurerm_data_factory_linked_service_azure_blob_storage" "test" { name = "acctestlsblob%d" resource_group_name = azurerm_resource_group.test.name diff --git a/website/docs/r/data_factory_dataset_binary.html.markdown b/website/docs/r/data_factory_dataset_binary.html.markdown index bba122551f1f..2e0b0a1b1455 100644 --- a/website/docs/r/data_factory_dataset_binary.html.markdown +++ b/website/docs/r/data_factory_dataset_binary.html.markdown @@ -106,9 +106,9 @@ A `azure_blob_storage_location` block supports the following: * `container` - (Required) The container on the Azure Blob Storage Account hosting the file. -* `path` - (Required) The folder path to the file on the web server. +* `path` - (Optional) The folder path to the file in the blob container. -* `filename` - (Required) The filename of the file on the web server. +* `filename` - (Optional) The filename of the file in the blob container. --- @@ -121,7 +121,7 @@ A `sftp_server_location` block supports the following: ## Attributes Reference -In addition to the Arguments listed above - the following Attributes are exported: +In addition to the Arguments listed above - the following Attributes are exported: * `id` - The ID of the Data Factory Dataset.