Skip to content

Commit

Permalink
Cleaned up data source
Browse files Browse the repository at this point in the history
  • Loading branch information
theonlyames committed Aug 13, 2024
1 parent fe37da3 commit 2c73f8b
Showing 1 changed file with 0 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,8 @@ import (
"github.com/hashicorp/terraform-provider-azurerm/internal/sdk"
"github.com/hashicorp/terraform-provider-azurerm/utils"

// miParse "github.com/hashicorp/terraform-provider-azurerm/internal/services/mssqlmanagedinstance/parse"

miValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/mssql/validate"

// "github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/v5.0/sql" // nolint: staticcheck

// "github.com/hashicorp/go-azure-helpers/resourcemanager/identity"
// "github.com/hashicorp/go-azure-helpers/resourcemanager/location"

"github.com/hashicorp/terraform-provider-azurerm/internal/services/mssqlmanagedinstance/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/sql/parse"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
Expand All @@ -39,26 +32,6 @@ type MsSqlManagedDatabaseDataSourceModel struct {
PointInTimeRestore []PointInTimeRestore `tfschema:"point_in_time_restore"`
}

// type MsSqlManagedDatabaseModel struct {
// Name string `tfschema:"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"`
// }

// type LongTermRetentionPolicy struct {
// WeeklyRetention string `tfschema:"weekly_retention"`
// MonthlyRetention string `tfschema:"monthly_retention"`
// YearlyRetention string `tfschema:"yearly_retention"`
// WeekOfYear int64 `tfschema:"week_of_year"`
// }

// type PointInTimeRestore struct {
// RestorePointInTime string `tfschema:"restore_point_in_time"`
// SourceDatabaseId string `tfschema:"source_database_id"`
// }

var _ sdk.DataSource = MsSqlManagedDatabaseDataSource{}

type MsSqlManagedDatabaseDataSource struct{}
Expand Down Expand Up @@ -89,12 +62,6 @@ func (d MsSqlManagedDatabaseDataSource) Arguments() map[string]*pluginsdk.Schema
ValidateFunc: miValidate.ValidateMsSqlServerName,
},
"resource_group_name": commonschema.ResourceGroupNameForDataSource(),
// "managed_instance_id": {
// Type: pluginsdk.TypeString,
// Required: true,
// ForceNew: true,
// ValidateFunc: validate.ManagedInstanceID,
// },
}
}

Expand Down Expand Up @@ -173,12 +140,7 @@ func (d MsSqlManagedDatabaseDataSource) Read() sdk.ResourceFunc {
return fmt.Errorf("decoding: %+v)", err)
}

// managedInstanceId, err := parse.ManagedInstanceID(state.ManagedInstanceId)
managedInstanceId := parse.NewManagedInstanceID(subscriptionId, state.ResourceGroupName, state.ManagedInstanceName)
// if err != nil {
// return err
// }

id := parse.NewManagedDatabaseID(subscriptionId, managedInstanceId.ResourceGroup, managedInstanceId.Name, state.Name)
resp, err := client.Get(ctx, id.ResourceGroup, id.ManagedInstanceName, id.DatabaseName)
if err != nil {
Expand All @@ -195,7 +157,6 @@ func (d MsSqlManagedDatabaseDataSource) Read() sdk.ResourceFunc {
}

model.ManagedInstanceId = managedInstanceId.ID()
//! MY STUFF END

ltrResp, err := longTermRetentionClient.Get(ctx, id.ResourceGroup, id.ManagedInstanceName, id.DatabaseName)
if err != nil {
Expand Down

0 comments on commit 2c73f8b

Please sign in to comment.