diff --git a/internal/services/mssqlmanagedinstance/mssql_managed_database_data_source.go b/internal/services/mssqlmanagedinstance/mssql_managed_database_data_source.go index 5ab41bfac5deb..61efbcc66836c 100644 --- a/internal/services/mssqlmanagedinstance/mssql_managed_database_data_source.go +++ b/internal/services/mssqlmanagedinstance/mssql_managed_database_data_source.go @@ -23,10 +23,10 @@ import ( ) type MsSqlManagedDatabaseDataSourceModel struct { - Name string `tfschema:"name"` - ResourceGroupName string `tfschema:"resource_group_name"` - ManagedInstanceName string `tfschema:"managed_instance_name"` - ManagedInstanceId string `tfschema:"managed_instance_id"` + Name string `tfschema:"name"` + ResourceGroupName string `tfschema:"resource_group_name"` + ManagedInstanceName string `tfschema:"managed_instance_name"` + ManagedInstanceId string `tfschema:"managed_instance_id"` LongTermRetentionPolicy []LongTermRetentionPolicy `tfschema:"long_term_retention_policy"` ShortTermRetentionDays int64 `tfschema:"short_term_retention_days"` PointInTimeRestore []PointInTimeRestore `tfschema:"point_in_time_restore"` @@ -68,8 +68,8 @@ func (d MsSqlManagedDatabaseDataSource) Arguments() map[string]*pluginsdk.Schema func (d MsSqlManagedDatabaseDataSource) Attributes() map[string]*pluginsdk.Schema { return map[string]*pluginsdk.Schema{ "managed_instance_id": { - Type: pluginsdk.TypeString, - Computed: true, + Type: pluginsdk.TypeString, + Computed: true, }, "long_term_retention_policy": { Type: pluginsdk.TypeList, @@ -78,32 +78,32 @@ func (d MsSqlManagedDatabaseDataSource) Attributes() map[string]*pluginsdk.Schem Schema: map[string]*pluginsdk.Schema{ // WeeklyRetention - The weekly retention policy for an LTR backup in an ISO 8601 format. "weekly_retention": { - Type: pluginsdk.TypeString, - Optional: true, - Computed: true, + Type: pluginsdk.TypeString, + Optional: true, + Computed: true, }, - + // MonthlyRetention - The monthly retention policy for an LTR backup in an ISO 8601 format. "monthly_retention": { - Type: pluginsdk.TypeString, - Optional: true, - Computed: true, + Type: pluginsdk.TypeString, + Optional: true, + Computed: true, }, - + // YearlyRetention - The yearly retention policy for an LTR backup in an ISO 8601 format. "yearly_retention": { - Type: pluginsdk.TypeString, - Optional: true, - Computed: true, + Type: pluginsdk.TypeString, + Optional: true, + Computed: true, }, - + // WeekOfYear - The week of year to take the yearly backup in an ISO 8601 format. "week_of_year": { - Type: pluginsdk.TypeInt, - Optional: true, - Computed: true, + Type: pluginsdk.TypeInt, + Optional: true, + Computed: true, }, - + "immutable_backups_enabled": { Type: pluginsdk.TypeBool, Optional: true, @@ -133,8 +133,6 @@ func (d MsSqlManagedDatabaseDataSource) Read() sdk.ResourceFunc { longTermRetentionClient := metadata.Client.MSSQLManagedInstance.ManagedInstancesLongTermRetentionPoliciesClient shortTermRetentionClient := metadata.Client.MSSQLManagedInstance.ManagedInstancesShortTermRetentionPoliciesClient - - var state MsSqlManagedDatabaseDataSourceModel if err := metadata.Decode(&state); err != nil { return fmt.Errorf("decoding: %+v)", err) @@ -151,7 +149,7 @@ func (d MsSqlManagedDatabaseDataSource) Read() sdk.ResourceFunc { } model := MsSqlManagedDatabaseDataSourceModel{ - Name: id.DatabaseName, + Name: id.DatabaseName, ManagedInstanceName: managedInstanceId.Name, ResourceGroupName: id.ResourceGroup, } diff --git a/internal/services/mssqlmanagedinstance/mssql_managed_database_data_source_test.go b/internal/services/mssqlmanagedinstance/mssql_managed_database_data_source_test.go index 91be556faa0f7..f5f6ed5614347 100644 --- a/internal/services/mssqlmanagedinstance/mssql_managed_database_data_source_test.go +++ b/internal/services/mssqlmanagedinstance/mssql_managed_database_data_source_test.go @@ -14,24 +14,24 @@ import ( type MsSqlManagedDatabaseDataSource struct{} func TestAccDataSourceMsSqlManagedDatabase_basic(t *testing.T) { - data := acceptance.BuildTestData(t, "data.azurerm_mssql_managed_database", "test") - - data.DataSourceTest(t, []acceptance.TestStep{ - { - Config: MsSqlManagedDatabaseDataSource{}.basic(data), - Check: acceptance.ComposeTestCheckFunc( - // check.That(data.ResourceName).Key("location").Exists(), - check.That(data.ResourceName).Key("name").Exists(), - check.That(data.ResourceName).Key("resource_group_name").Exists(), - // check.That(data.ResourceName).Key("tags.%").HasValue("2"), - check.That(data.ResourceName).Key("managed_instance_name").Exists(), - ), - }, - }) + data := acceptance.BuildTestData(t, "data.azurerm_mssql_managed_database", "test") + + data.DataSourceTest(t, []acceptance.TestStep{ + { + Config: MsSqlManagedDatabaseDataSource{}.basic(data), + Check: acceptance.ComposeTestCheckFunc( + // check.That(data.ResourceName).Key("location").Exists(), + check.That(data.ResourceName).Key("name").Exists(), + check.That(data.ResourceName).Key("resource_group_name").Exists(), + // check.That(data.ResourceName).Key("tags.%").HasValue("2"), + check.That(data.ResourceName).Key("managed_instance_name").Exists(), + ), + }, + }) } func (d MsSqlManagedDatabaseDataSource) basic(data acceptance.TestData) string { - return fmt.Sprintf(` + return fmt.Sprintf(` %[1]s data "azurerm_mssql_managed_database" "test" {