From dc56d01b798f195a4d9eea0f7033f8cb60b880dc Mon Sep 17 00:00:00 2001 From: Sebastian Heid <8442432+s4heid@users.noreply.github.com> Date: Fri, 10 Jan 2025 08:51:24 +0100 Subject: [PATCH] Apply suggestions from code review Co-authored-by: stephybun --- .../costmanagement/anomaly_alert_resource.go | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/internal/services/costmanagement/anomaly_alert_resource.go b/internal/services/costmanagement/anomaly_alert_resource.go index a5f651e9ff01..b46dae0a671c 100644 --- a/internal/services/costmanagement/anomaly_alert_resource.go +++ b/internal/services/costmanagement/anomaly_alert_resource.go @@ -124,13 +124,10 @@ func (r AnomalyAlertResource) Create() sdk.ResourceFunc { schedule.SetEndDateAsTime(time.Now().AddDate(1, 0, 0)) schedule.SetStartDateAsTime(time.Now()) - var senderEmail string + notificationEmail := (*emailAddresses)[0] if v, ok := metadata.ResourceData.GetOk("notification_email"); ok { - senderEmail = v.(string) - } else { - senderEmail = (*emailAddresses)[0] + notificationEmail = v.(string) } - param := scheduledactions.ScheduledAction{ Kind: pointer.To(scheduledactions.ScheduledActionKindInsightAlert), Properties: &scheduledactions.ScheduledActionProperties{ @@ -149,7 +146,7 @@ func (r AnomalyAlertResource) Create() sdk.ResourceFunc { Schedule: schedule, }, } - if _, err := client.CreateOrUpdateByScope(ctx, id, param, scheduledactions.CreateOrUpdateByScopeOperationOptions{}); err != nil { + if _, err := client.CreateOrUpdateByScope(ctx, id, param, scheduledactions.DefaultCreateOrUpdateByScopeOperationOptions()); err != nil { return fmt.Errorf("creating %s: %+v", id, err) } @@ -198,13 +195,10 @@ func (r AnomalyAlertResource) Update() sdk.ResourceFunc { schedule.SetEndDateAsTime(time.Now().AddDate(1, 0, 0)) schedule.SetStartDateAsTime(time.Now()) - var senderEmail string + notificationEmail := (*emailAddresses)[0] if v, ok := metadata.ResourceData.GetOk("notification_email"); ok { - senderEmail = v.(string) - } else { - senderEmail = (*emailAddresses)[0] + notificationEmail = v.(string) } - param := scheduledactions.ScheduledAction{ Kind: pointer.To(scheduledactions.ScheduledActionKindInsightAlert), ETag: resp.Model.ETag, @@ -221,7 +215,7 @@ func (r AnomalyAlertResource) Update() sdk.ResourceFunc { Schedule: schedule, }, } - if _, err := client.CreateOrUpdateByScope(ctx, *id, param, scheduledactions.CreateOrUpdateByScopeOperationOptions{}); err != nil { + if _, err := client.CreateOrUpdateByScope(ctx, *id, param, scheduledactions.DefaultCreateOrUpdateByScopeOperationOptions()); err != nil { return fmt.Errorf("creating %s: %+v", id, err) }