Skip to content

Commit

Permalink
fix GH issue 25399
Browse files Browse the repository at this point in the history
  • Loading branch information
sinbai committed Mar 26, 2024
1 parent 7709fe9 commit 79bab8b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ func (r AlertPrometheusRuleGroupResource) Create() sdk.ResourceFunc {
if _, ok := metadata.ResourceData.GetOk("interval"); ok {
properties.Properties.Interval = pointer.To(model.Interval)
}
properties.Properties.Rules = expandPrometheusRuleModel(model.Rule)
properties.Properties.Rules = expandPrometheusRuleModel(model.Rule, *metadata.ResourceData)

Check failure on line 296 in internal/services/monitor/monitor_alert_prometheus_rule_group_resource.go

View workflow job for this annotation

GitHub Actions / golint

copylocks: call of expandPrometheusRuleModel copies lock value: github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.ResourceData contains sync.Once contains sync.Mutex (govet)

if _, err := client.CreateOrUpdate(ctx, id, properties); err != nil {
return fmt.Errorf("creating %s: %+v", id, err)
Expand Down Expand Up @@ -344,7 +344,7 @@ func (r AlertPrometheusRuleGroupResource) Update() sdk.ResourceFunc {
properties.Properties.Interval = pointer.To(model.Interval)
}
if metadata.ResourceData.HasChange("rule") {
properties.Properties.Rules = expandPrometheusRuleModel(model.Rule)
properties.Properties.Rules = expandPrometheusRuleModel(model.Rule, *metadata.ResourceData)

Check failure on line 347 in internal/services/monitor/monitor_alert_prometheus_rule_group_resource.go

View workflow job for this annotation

GitHub Actions / golint

copylocks: call of expandPrometheusRuleModel copies lock value: github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.ResourceData contains sync.Once contains sync.Mutex (govet)
}
if metadata.ResourceData.HasChange("scopes") {
properties.Properties.Scopes = model.Scopes
Expand Down Expand Up @@ -422,7 +422,7 @@ func (r AlertPrometheusRuleGroupResource) Delete() sdk.ResourceFunc {
}
}

func expandPrometheusRuleModel(inputList []PrometheusRuleModel) []prometheusrulegroups.PrometheusRule {
func expandPrometheusRuleModel(inputList []PrometheusRuleModel, d schema.ResourceData) []prometheusrulegroups.PrometheusRule {

Check failure on line 425 in internal/services/monitor/monitor_alert_prometheus_rule_group_resource.go

View workflow job for this annotation

GitHub Actions / golint

copylocks: expandPrometheusRuleModel passes lock by value: github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.ResourceData contains sync.Once contains sync.Mutex (govet)
outputList := make([]prometheusrulegroups.PrometheusRule, 0)

for _, v := range inputList {
Expand All @@ -435,8 +435,8 @@ func expandPrometheusRuleModel(inputList []PrometheusRuleModel) []prometheusrule
if v.Alert != "" {
output.Actions = expandPrometheusRuleGroupActionModel(v.Action)
output.Alert = pointer.To(v.Alert)
if v.Severity != 0 {
output.Severity = pointer.To(int64(v.Severity))
if v, ok := d.GetOk("severity"); ok {
output.Severity = pointer.To(int64(v.(int)))
}
output.Annotations = pointer.To(v.Annotations)
output.For = pointer.To(v.For)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ EOF
histogram_quantile(0.99, sum(rate(jobs_duration_seconds_bucket{service="billing-processing"}[5m])) by (job_type))
EOF
for = "PT5M"
severity = 2
severity = 0
action {
action_group_id = azurerm_monitor_action_group.test.id
}
Expand Down

0 comments on commit 79bab8b

Please sign in to comment.