diff --git a/fastly/resource_fastly_alert.go b/fastly/resource_fastly_alert.go index ee87ee4d9..febde8ccc 100644 --- a/fastly/resource_fastly_alert.go +++ b/fastly/resource_fastly_alert.go @@ -60,7 +60,7 @@ func resourceFastlyAlert() *schema.Resource { "ignore_below": { Type: schema.TypeFloat, Optional: true, - Description: "Floor noise that can be configured to ignore data points that are below this threshold.", + Description: "Threshold for the denominator value used in evaluations that calculate a rate or ratio. Usually used to filter out noise.", }, "period": { Type: schema.TypeString, @@ -296,25 +296,19 @@ func buildDimensions(data map[string][]string, v map[string]any) map[string][]st } func buildEvaluationStrategy(v map[string]any) map[string]any { - evaluationStrategy := map[string]any{} - - if value, ok := v["type"]; ok { - evaluationStrategy["type"] = value.(string) - } - - if value, ok := v["period"]; ok { - evaluationStrategy["period"] = value.(string) - } - - if value, ok := v["threshold"]; ok { - evaluationStrategy["threshold"] = value.(float64) + // Required attributes + m := map[string]any{ + "type": v["type"].(string), + "period": v["period"].(string), + "threshold": v["threshold"].(float64), } + // Optional attributes if value, ok := v["ignore_below"]; ok { - evaluationStrategy["ignore_below"] = value.(float64) + m["ignore_below"] = value.(float64) } - return evaluationStrategy + return m } func buildStringSlice(s *schema.Set) []string { diff --git a/fastly/resource_fastly_alert_test.go b/fastly/resource_fastly_alert_test.go index cf6cfbc8d..7346439ac 100644 --- a/fastly/resource_fastly_alert_test.go +++ b/fastly/resource_fastly_alert_test.go @@ -12,7 +12,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) -func TestAccFastlyAlert_basic(t *testing.T) { +func TestAccFastlyAlertBasic(t *testing.T) { var service gofastly.ServiceDetail serviceName := fmt.Sprintf("tf-test-%s", acctest.RandString(10)) domainName := fmt.Sprintf("fastly-test.tf-%s.com", acctest.RandString(10)) @@ -75,7 +75,7 @@ func TestAccFastlyAlert_basic(t *testing.T) { }) } -func TestAccFastlyAlert_basic_stats(t *testing.T) { +func TestAccFastlyAlertBasicStats(t *testing.T) { var service gofastly.ServiceDetail serviceName := fmt.Sprintf("tf-test-%s", acctest.RandString(10)) domainName := fmt.Sprintf("fastly-test.tf-%s.com", acctest.RandString(10)) @@ -134,7 +134,7 @@ func TestAccFastlyAlert_basic_stats(t *testing.T) { }) } -func TestAccFastlyAlert_basic_stats_aggregate(t *testing.T) { +func TestAccFastlyAlertBasicStatsAggregate(t *testing.T) { service := gofastly.ServiceDetail{ Name: gofastly.ToPointer(""), ServiceID: gofastly.ToPointer(""), @@ -193,7 +193,7 @@ func TestAccFastlyAlert_basic_stats_aggregate(t *testing.T) { }) } -func TestAccFastlyAlert_basic_stats_aggregate_percent(t *testing.T) { +func TestAccFastlyAlertBasicStatsAggregatePercent(t *testing.T) { service := gofastly.ServiceDetail{ Name: gofastly.ToPointer(""), ServiceID: gofastly.ToPointer(""),