Skip to content

Commit

Permalink
point.to
Browse files Browse the repository at this point in the history
  • Loading branch information
katbyte committed Nov 1, 2024
1 parent f082622 commit e084785
Showing 1 changed file with 6 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ func (r MsSqlManagedDatabaseResource) Create() sdk.ResourceFunc {

parameters := manageddatabases.ManagedDatabase{
Location: managedInstance.Model.Location,
Properties: &manageddatabases.ManagedDatabaseProperties{},
Tags: &model.Tags,
Properties: pointer.To(manageddatabases.ManagedDatabaseProperties{}),
Tags: pointer.To(model.Tags),
}

if len(model.PointInTimeRestore) > 0 {
Expand All @@ -184,10 +184,8 @@ func (r MsSqlManagedDatabaseResource) Create() sdk.ResourceFunc {
}

if len(model.LongTermRetentionPolicy) > 0 {
longTermRetentionProps := expandLongTermRetentionPolicy(model.LongTermRetentionPolicy)

longTermRetentionPolicy := managedinstancelongtermretentionpolicies.ManagedInstanceLongTermRetentionPolicy{
Properties: &longTermRetentionProps,
Properties: pointer.To(expandLongTermRetentionPolicy(model.LongTermRetentionPolicy)),
}

err := longTermRetentionClient.CreateOrUpdateThenPoll(ctx, id, longTermRetentionPolicy)
Expand All @@ -197,7 +195,6 @@ func (r MsSqlManagedDatabaseResource) Create() sdk.ResourceFunc {
}

if model.ShortTermRetentionDays > 0 {

shortTermRetentionPolicy := managedbackupshorttermretentionpolicies.ManagedBackupShortTermRetentionPolicy{
Properties: &managedbackupshorttermretentionpolicies.ManagedBackupShortTermRetentionPolicyProperties{
RetentionDays: pointer.To(model.ShortTermRetentionDays),
Expand Down Expand Up @@ -240,7 +237,7 @@ func (r MsSqlManagedDatabaseResource) Update() sdk.ResourceFunc {

if d.HasChange("tags") {
parameters := manageddatabases.ManagedDatabase{
Tags: &model.Tags,
Tags: pointer.To(model.Tags),
}

err = client.CreateOrUpdateThenPoll(ctx, id, parameters)
Expand All @@ -250,10 +247,8 @@ func (r MsSqlManagedDatabaseResource) Update() sdk.ResourceFunc {
}

if d.HasChange("long_term_retention_policy") {
longTermRetentionProps := expandLongTermRetentionPolicy(model.LongTermRetentionPolicy)

longTermRetentionPolicy := managedinstancelongtermretentionpolicies.ManagedInstanceLongTermRetentionPolicy{
Properties: &longTermRetentionProps,
Properties: pointer.To(expandLongTermRetentionPolicy(model.LongTermRetentionPolicy)),
}

err := longTermRetentionClient.CreateOrUpdateThenPoll(ctx, id, longTermRetentionPolicy)
Expand All @@ -263,7 +258,6 @@ func (r MsSqlManagedDatabaseResource) Update() sdk.ResourceFunc {
}

if d.HasChange("short_term_retention_days") {

shortTermRetentionPolicy := managedbackupshorttermretentionpolicies.ManagedBackupShortTermRetentionPolicy{
Properties: &managedbackupshorttermretentionpolicies.ManagedBackupShortTermRetentionPolicyProperties{
RetentionDays: pointer.To(model.ShortTermRetentionDays),
Expand Down Expand Up @@ -335,9 +329,7 @@ func (r MsSqlManagedDatabaseResource) Read() sdk.ResourceFunc {
model.PointInTimeRestore = flattenManagedDatabasePointInTimeRestore(v)
}

if model.Tags != nil {
state.Tags = model.Tags
}
state.Tags = model.Tags

return metadata.Encode(&model)
},
Expand Down

0 comments on commit e084785

Please sign in to comment.