Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: stephybun <steph@hashicorp.com>
  • Loading branch information
s4heid and stephybun authored Jan 10, 2025
1 parent 545b720 commit dc56d01
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions internal/services/costmanagement/anomaly_alert_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Check failure on line 127 in internal/services/costmanagement/anomaly_alert_resource.go

View workflow job for this annotation

GitHub Actions / test

notificationEmail declared and not used

Check failure on line 127 in internal/services/costmanagement/anomaly_alert_resource.go

View workflow job for this annotation

GitHub Actions / tflint

notificationEmail declared and not used

Check failure on line 127 in internal/services/costmanagement/anomaly_alert_resource.go

View workflow job for this annotation

GitHub Actions / tflint

notificationEmail declared and not used

Check failure on line 127 in internal/services/costmanagement/anomaly_alert_resource.go

View workflow job for this annotation

GitHub Actions / detect

notificationEmail declared and not used

Check failure on line 127 in internal/services/costmanagement/anomaly_alert_resource.go

View workflow job for this annotation

GitHub Actions / golint

notificationEmail declared and not used

Check failure on line 127 in internal/services/costmanagement/anomaly_alert_resource.go

View workflow job for this annotation

GitHub Actions / golint

notificationEmail declared and not used

Check failure on line 127 in internal/services/costmanagement/anomaly_alert_resource.go

View workflow job for this annotation

GitHub Actions / document-lint

notificationEmail declared and not used

Check failure on line 127 in internal/services/costmanagement/anomaly_alert_resource.go

View workflow job for this annotation

GitHub Actions / compatibility-32bit-test

notificationEmail declared and not used
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{
Expand All @@ -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)
}

Expand Down Expand Up @@ -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]

Check failure on line 198 in internal/services/costmanagement/anomaly_alert_resource.go

View workflow job for this annotation

GitHub Actions / test

notificationEmail declared and not used

Check failure on line 198 in internal/services/costmanagement/anomaly_alert_resource.go

View workflow job for this annotation

GitHub Actions / tflint

notificationEmail declared and not used

Check failure on line 198 in internal/services/costmanagement/anomaly_alert_resource.go

View workflow job for this annotation

GitHub Actions / tflint

notificationEmail declared and not used

Check failure on line 198 in internal/services/costmanagement/anomaly_alert_resource.go

View workflow job for this annotation

GitHub Actions / detect

notificationEmail declared and not used

Check failure on line 198 in internal/services/costmanagement/anomaly_alert_resource.go

View workflow job for this annotation

GitHub Actions / golint

notificationEmail declared and not used

Check failure on line 198 in internal/services/costmanagement/anomaly_alert_resource.go

View workflow job for this annotation

GitHub Actions / golint

notificationEmail declared and not used

Check failure on line 198 in internal/services/costmanagement/anomaly_alert_resource.go

View workflow job for this annotation

GitHub Actions / document-lint

notificationEmail declared and not used

Check failure on line 198 in internal/services/costmanagement/anomaly_alert_resource.go

View workflow job for this annotation

GitHub Actions / compatibility-32bit-test

notificationEmail declared and not used
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,
Expand All @@ -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)
}

Expand Down

0 comments on commit dc56d01

Please sign in to comment.