Skip to content

Commit

Permalink
Bugfix: azurerm_data_factory_dataset_binary - Make blob path/filena…
Browse files Browse the repository at this point in the history
…me optional (#12676)
  • Loading branch information
henrymcconville authored Jul 27, 2021
1 parent 40e3aca commit e45c594
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions website/docs/r/data_factory_dataset_binary.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.

---

Expand All @@ -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.

Expand Down

0 comments on commit e45c594

Please sign in to comment.