From 11df4fdf1f3bd8d11068b9093ddc4714d8c226a4 Mon Sep 17 00:00:00 2001 From: Matthew Frahry Date: Mon, 25 Apr 2022 11:45:26 -0700 Subject: [PATCH] Update changelog for #16514 --- CHANGELOG.md | 1 + ...ta_factory_dataset_binary_resource_test.go | 70 ++++++++++++++++ ...factory_dataset_delimited_text_resource.go | 5 ++ ...ry_dataset_delimited_text_resource_test.go | 79 +++++++++++++++++++ .../data_factory_dataset_json_resource.go | 5 ++ ...data_factory_dataset_json_resource_test.go | 29 +++---- .../data_factory_dataset_parquet_resource.go | 5 ++ ...a_factory_dataset_parquet_resource_test.go | 24 ++---- 8 files changed, 180 insertions(+), 38 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f273903eb0cc..3957bb6681e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ ENHANCEMENTS: BUG FIXES: +* `azurerm_datafactory_dataset_x` - Fix crash around `azure_blob_storage_location.0.dynamic_container_enabled` [GH-16514] * `azurerm_resource_policy_remediation` - will no longer try to cancel a completed remediation task during deletion [GH-16478] ## 3.3.0 (April 21, 2022) diff --git a/internal/services/datafactory/data_factory_dataset_binary_resource_test.go b/internal/services/datafactory/data_factory_dataset_binary_resource_test.go index 6a0447505723..fd4c4392f774 100644 --- a/internal/services/datafactory/data_factory_dataset_binary_resource_test.go +++ b/internal/services/datafactory/data_factory_dataset_binary_resource_test.go @@ -30,6 +30,21 @@ func TestAccDataFactoryDatasetBinary_blob(t *testing.T) { }) } +func TestAccDataFactoryDatasetBinary_blob_dynamics(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_data_factory_dataset_binary", "test") + r := DatasetBinaryResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.blob_dynamics(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + func TestAccDataFactoryDatasetBinary_blob_with_filepath(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_data_factory_dataset_binary", "test") r := DatasetBinaryResource{} @@ -183,6 +198,61 @@ resource "azurerm_data_factory_dataset_binary" "test" { `, data.RandomInteger, data.Locations.Primary, data.RandomString, data.RandomInteger, data.RandomInteger, data.RandomInteger) } +func (DatasetBinaryResource) blob_dynamics(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" + data_factory_id = azurerm_data_factory.test.id + connection_string = azurerm_storage_account.test.primary_connection_string +} + +resource "azurerm_data_factory_dataset_binary" "test" { + name = "acctestds%d" + data_factory_id = azurerm_data_factory.test.id + linked_service_name = azurerm_data_factory_linked_service_azure_blob_storage.test.name + + azure_blob_storage_location { + container = "@concat(azurerm_storage_container.test.name, '')" + dynamic_container_enabled = true + path = "@concat('foo/bar/',formatDateTime(convertTimeZone(utcnow(),'UTC','W. Europe Standard Time'),'yyyy-MM-dd'))" + dynamic_path_enabled = true + filename = "@concat('foo', '.txt')" + dynamic_filename_enabled = true + } +} +`, 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" { diff --git a/internal/services/datafactory/data_factory_dataset_delimited_text_resource.go b/internal/services/datafactory/data_factory_dataset_delimited_text_resource.go index 45efbc6ff643..7ba0333018e9 100644 --- a/internal/services/datafactory/data_factory_dataset_delimited_text_resource.go +++ b/internal/services/datafactory/data_factory_dataset_delimited_text_resource.go @@ -115,6 +115,11 @@ func resourceDataFactoryDatasetDelimitedText() *pluginsdk.Resource { Type: pluginsdk.TypeString, Optional: true, }, + "dynamic_container_enabled": { + Type: pluginsdk.TypeBool, + Optional: true, + Default: false, + }, "dynamic_path_enabled": { Type: pluginsdk.TypeBool, Optional: true, diff --git a/internal/services/datafactory/data_factory_dataset_delimited_text_resource_test.go b/internal/services/datafactory/data_factory_dataset_delimited_text_resource_test.go index da8fad522933..323a5e602a4b 100644 --- a/internal/services/datafactory/data_factory_dataset_delimited_text_resource_test.go +++ b/internal/services/datafactory/data_factory_dataset_delimited_text_resource_test.go @@ -104,6 +104,21 @@ func TestAccDataFactoryDatasetDelimitedText_blob(t *testing.T) { }) } +func TestAccDataFactoryDatasetDelimitedText_blob_dynamics(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_data_factory_dataset_delimited_text", "test") + r := DatasetDelimitedTextResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.blob_dynamics(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + func TestAccDataFactoryDatasetDelimitedText_blob_empty_path(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_data_factory_dataset_delimited_text", "test") r := DatasetDelimitedTextResource{} @@ -488,6 +503,70 @@ resource "azurerm_data_factory_dataset_delimited_text" "test" { `, data.RandomInteger, data.Locations.Primary, data.RandomString, data.RandomInteger, data.RandomInteger, data.RandomInteger) } +func (DatasetDelimitedTextResource) blob_dynamics(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" + data_factory_id = azurerm_data_factory.test.id + connection_string = azurerm_storage_account.test.primary_connection_string +} + +resource "azurerm_data_factory_dataset_delimited_text" "test" { + name = "acctestds%d" + data_factory_id = azurerm_data_factory.test.id + linked_service_name = azurerm_data_factory_linked_service_azure_blob_storage.test.name + + azure_blob_storage_location { + container = "@concat(azurerm_storage_container.test.name, '')" + dynamic_container_enabled = true + path = "@concat('foo/bar/',formatDateTime(convertTimeZone(utcnow(),'UTC','W. Europe Standard Time'),'yyyy-MM-dd'))" + dynamic_path_enabled = true + filename = "@concat('foo', '.txt')" + dynamic_filename_enabled = true + } + + column_delimiter = "," + row_delimiter = "NEW" + encoding = "UTF-8" + quote_character = "x" + escape_character = "f" + first_row_as_header = true + null_value = "NULL" + +} +`, data.RandomInteger, data.Locations.Primary, data.RandomString, data.RandomInteger, data.RandomInteger, data.RandomInteger) +} + func (DatasetDelimitedTextResource) blob_empty_path(data acceptance.TestData) string { return fmt.Sprintf(` provider "azurerm" { diff --git a/internal/services/datafactory/data_factory_dataset_json_resource.go b/internal/services/datafactory/data_factory_dataset_json_resource.go index 36b6bd446aa3..db828323c766 100644 --- a/internal/services/datafactory/data_factory_dataset_json_resource.go +++ b/internal/services/datafactory/data_factory_dataset_json_resource.go @@ -118,6 +118,11 @@ func resourceDataFactoryDatasetJSON() *pluginsdk.Resource { Required: true, ValidateFunc: validation.StringIsNotEmpty, }, + "dynamic_container_enabled": { + Type: pluginsdk.TypeBool, + Optional: true, + Default: false, + }, "dynamic_path_enabled": { Type: pluginsdk.TypeBool, Optional: true, diff --git a/internal/services/datafactory/data_factory_dataset_json_resource_test.go b/internal/services/datafactory/data_factory_dataset_json_resource_test.go index 0edd79dc2c05..f8087a3cd76a 100644 --- a/internal/services/datafactory/data_factory_dataset_json_resource_test.go +++ b/internal/services/datafactory/data_factory_dataset_json_resource_test.go @@ -77,27 +77,13 @@ func TestAccDataFactoryDatasetJSON_blob(t *testing.T) { }) } -func TestAccDataFactoryDatasetJSON_blobDynamicContainer(t *testing.T) { +func TestAccDataFactoryDatasetJSON_blob_dynamics(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_data_factory_dataset_json", "test") r := DatasetJSONResource{} data.ResourceTest(t, r, []acceptance.TestStep{ { - Config: r.blob(data), - Check: acceptance.ComposeTestCheckFunc( - check.That(data.ResourceName).ExistsInAzure(r), - ), - }, - data.ImportStep(), - { - Config: r.blobDynamicContainer(data), - Check: acceptance.ComposeTestCheckFunc( - check.That(data.ResourceName).ExistsInAzure(r), - ), - }, - data.ImportStep(), - { - Config: r.blob(data), + Config: r.blob_dynamics(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), ), @@ -345,7 +331,7 @@ resource "azurerm_data_factory_dataset_json" "test" { `, data.RandomInteger, data.Locations.Primary, data.RandomString, data.RandomInteger, data.RandomInteger, data.RandomInteger) } -func (DatasetJSONResource) blobDynamicContainer(data acceptance.TestData) string { +func (DatasetJSONResource) blob_dynamics(data acceptance.TestData) string { return fmt.Sprintf(` provider "azurerm" { features {} @@ -389,13 +375,16 @@ resource "azurerm_data_factory_dataset_json" "test" { linked_service_name = azurerm_data_factory_linked_service_azure_blob_storage.test.name azure_blob_storage_location { - container = azurerm_storage_container.test.name + container = "@concat(azurerm_storage_container.test.name, '')" dynamic_container_enabled = true path = "@concat('foo/bar/',formatDateTime(convertTimeZone(utcnow(),'UTC','W. Europe Standard Time'),'yyyy-MM-dd'))" dynamic_path_enabled = true - filename = "foo.json" - dynamic_filename_enabled = false + filename = "@concat('foo', '.txt')" + dynamic_filename_enabled = true } + + encoding = "UTF-8" + } `, data.RandomInteger, data.Locations.Primary, data.RandomString, data.RandomInteger, data.RandomInteger, data.RandomInteger) } diff --git a/internal/services/datafactory/data_factory_dataset_parquet_resource.go b/internal/services/datafactory/data_factory_dataset_parquet_resource.go index edb1ff178f3a..df10d78d71a9 100644 --- a/internal/services/datafactory/data_factory_dataset_parquet_resource.go +++ b/internal/services/datafactory/data_factory_dataset_parquet_resource.go @@ -95,6 +95,11 @@ func resourceDataFactoryDatasetParquet() *pluginsdk.Resource { Required: true, ValidateFunc: validation.StringIsNotEmpty, }, + "dynamic_container_enabled": { + Type: pluginsdk.TypeBool, + Optional: true, + Default: false, + }, "dynamic_path_enabled": { Type: pluginsdk.TypeBool, Optional: true, diff --git a/internal/services/datafactory/data_factory_dataset_parquet_resource_test.go b/internal/services/datafactory/data_factory_dataset_parquet_resource_test.go index 7bef46c4d14c..aaf779f1b215 100644 --- a/internal/services/datafactory/data_factory_dataset_parquet_resource_test.go +++ b/internal/services/datafactory/data_factory_dataset_parquet_resource_test.go @@ -79,27 +79,13 @@ func TestAccDataFactoryDatasetParquet_blob(t *testing.T) { }) } -func TestAccDataFactoryDatasetParquet_blobDynamicContainer(t *testing.T) { +func TestAccDataFactoryDatasetParquet_blob_dynamics(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_data_factory_dataset_parquet", "test") r := DatasetParquetResource{} data.ResourceTest(t, r, []acceptance.TestStep{ { - Config: r.blob(data), - Check: acceptance.ComposeTestCheckFunc( - check.That(data.ResourceName).ExistsInAzure(r), - ), - }, - data.ImportStep(), - { - Config: r.blobDynamicContainer(data), - Check: acceptance.ComposeTestCheckFunc( - check.That(data.ResourceName).ExistsInAzure(r), - ), - }, - data.ImportStep(), - { - Config: r.blob(data), + Config: r.blob_dynamics(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), ), @@ -342,7 +328,7 @@ resource "azurerm_data_factory_dataset_parquet" "test" { `, data.RandomInteger, data.Locations.Primary, data.RandomString, data.RandomInteger, data.RandomInteger, data.RandomInteger) } -func (DatasetParquetResource) blobDynamicContainer(data acceptance.TestData) string { +func (DatasetParquetResource) blob_dynamics(data acceptance.TestData) string { return fmt.Sprintf(` provider "azurerm" { features {} @@ -386,10 +372,12 @@ resource "azurerm_data_factory_dataset_parquet" "test" { linked_service_name = azurerm_data_factory_linked_service_azure_blob_storage.test.name azure_blob_storage_location { - container = azurerm_storage_container.test.name + container = "@concat(azurerm_storage_container.test.name, '')" dynamic_container_enabled = true path = "@concat('foo/bar/',formatDateTime(convertTimeZone(utcnow(),'UTC','W. Europe Standard Time'),'yyyy-MM-dd'))" dynamic_path_enabled = true + filename = "@concat('foo', '.txt')" + dynamic_filename_enabled = true } } `, data.RandomInteger, data.Locations.Primary, data.RandomString, data.RandomInteger, data.RandomInteger, data.RandomInteger)