From 928e5458a60d1d6600792fa78c0e594305caf276 Mon Sep 17 00:00:00 2001 From: vagrawal-newrelic Date: Wed, 17 Jul 2024 14:07:27 +0530 Subject: [PATCH] fix(dashboard): update line and table widget threshold `to` and `from` datatype (#2713) Co-authored-by: pranav-new-relic <127438038+pranav-new-relic@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- newrelic/resource_newrelic_one_dashboard.go | 8 ++++---- .../resource_newrelic_one_dashboard_test.go | 20 +++++++++++++++---- newrelic/structures_newrelic_one_dashboard.go | 8 ++++---- website/docs/r/one_dashboard.html.markdown | 4 ++-- 6 files changed, 29 insertions(+), 17 deletions(-) diff --git a/go.mod b/go.mod index 9e597ada2..7f0bbcfd1 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/mitchellh/go-homedir v1.1.0 github.com/newrelic/go-agent/v3 v3.30.0 github.com/newrelic/go-insights v1.0.3 - github.com/newrelic/newrelic-client-go/v2 v2.41.0 + github.com/newrelic/newrelic-client-go/v2 v2.41.2 github.com/stretchr/testify v1.9.0 golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 ) diff --git a/go.sum b/go.sum index a59656753..15a05fe73 100644 --- a/go.sum +++ b/go.sum @@ -270,8 +270,8 @@ github.com/newrelic/go-agent/v3 v3.30.0 h1:ZXHCT/Cot4iIPwcegCZURuRQOsfmGA6wilW+S github.com/newrelic/go-agent/v3 v3.30.0/go.mod h1:9utrgxlSryNqRrTvII2XBL+0lpofXbqXApvVWPpbzUg= github.com/newrelic/go-insights v1.0.3 h1:zSNp1CEZnXktzSIEsbHJk8v6ZihdPFP2WsO/fzau3OQ= github.com/newrelic/go-insights v1.0.3/go.mod h1:A20BoT8TNkqPGX2nS/Z2fYmKl3Cqa3iKZd4whzedCY4= -github.com/newrelic/newrelic-client-go/v2 v2.41.0 h1:UD72MW+sYRViY8T5SciYwySuBe/oNN0/NGXman4dXeI= -github.com/newrelic/newrelic-client-go/v2 v2.41.0/go.mod h1:pDFY24/6iIMEbPIdowTRrRn9YYwkXc3j+B+XpTb4oF4= +github.com/newrelic/newrelic-client-go/v2 v2.41.2 h1:5YkFRSU19a9CoOkF8qgWoNRXVbL6qh0nZYaWbQjFppA= +github.com/newrelic/newrelic-client-go/v2 v2.41.2/go.mod h1:pDFY24/6iIMEbPIdowTRrRn9YYwkXc3j+B+XpTb4oF4= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= diff --git a/newrelic/resource_newrelic_one_dashboard.go b/newrelic/resource_newrelic_one_dashboard.go index 95e88c837..b31a17bd5 100644 --- a/newrelic/resource_newrelic_one_dashboard.go +++ b/newrelic/resource_newrelic_one_dashboard.go @@ -599,12 +599,12 @@ func dashboardWidgetLineSchemaElem() *schema.Resource { Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "from": { - Type: schema.TypeInt, + Type: schema.TypeFloat, Optional: true, Description: "The number from which the range starts in thresholds.", }, "to": { - Type: schema.TypeInt, + Type: schema.TypeFloat, Optional: true, Description: "The number at which the range ends in thresholds.", }, @@ -697,12 +697,12 @@ func dashboardWidgetTableSchemaElem() *schema.Resource { Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "from": { - Type: schema.TypeInt, + Type: schema.TypeFloat, Optional: true, Description: "The number from which the range starts in thresholds.", }, "to": { - Type: schema.TypeInt, + Type: schema.TypeFloat, Optional: true, Description: "The number at which the range ends in thresholds.", }, diff --git a/newrelic/resource_newrelic_one_dashboard_test.go b/newrelic/resource_newrelic_one_dashboard_test.go index 009c2e14a..528892773 100644 --- a/newrelic/resource_newrelic_one_dashboard_test.go +++ b/newrelic/resource_newrelic_one_dashboard_test.go @@ -726,6 +726,12 @@ func testAccCheckNewRelicOneDashboardConfig_PageFull(pageName string, accountID y_axis_right_zero = false y_axis_right_series = ["A", "B"] } + threshold { + name = "Duration Threshold" + from = 10.8 + to = 30.7 + severity = "critical" + } } widget_markdown { @@ -762,8 +768,8 @@ func testAccCheckNewRelicOneDashboardConfig_PageFull(pageName string, accountID query = "FROM Transaction SELECT average(duration) FACET appName" } threshold { - from = 100 - to = 200 + from = 100.1 + to = 200.2 column_name = "C1" severity = "unavailable" } @@ -961,8 +967,8 @@ func testAccCheckNewRelicOneDashboardConfig_PageFullChanged(pageName string, acc y_axis_left_max = 25 is_label_visible = true threshold { - from = 100 - to = 200 + from = 100.1 + to = 200.2 name = "T1" severity = "warning" } @@ -1004,6 +1010,12 @@ func testAccCheckNewRelicOneDashboardConfig_PageFullChanged(pageName string, acc nrql_query { query = "FROM Transaction SELECT average(duration) FACET appName LIMIT 10" } + threshold { + from = 100.2 + to = 200.4 + column_name = "C1" + severity = "unavailable" + } linked_entity_guids = ["MjUyMDUyOHxWSVp8REFTSEJPQVJEfDE2NDYzMDQ"] } diff --git a/newrelic/structures_newrelic_one_dashboard.go b/newrelic/structures_newrelic_one_dashboard.go index d12ed4981..4b552d4ab 100644 --- a/newrelic/structures_newrelic_one_dashboard.go +++ b/newrelic/structures_newrelic_one_dashboard.go @@ -504,11 +504,11 @@ func expandDashboardLineWidgetConfigurationThresholdInput(d *schema.ResourceData // and assign them to respective attributes of the DashboardLineWidgetThresholdThresholdInput object if v, ok := lineWidgetThresholdInInputSingularInterface["from"]; ok { - t := v.(int) + t := v.(float64) lineWidgetThresholdToBeAdded.From = &t } if v, ok := lineWidgetThresholdInInputSingularInterface["to"]; ok { - t := v.(int) + t := v.(float64) lineWidgetThresholdToBeAdded.To = &t } if v, ok := lineWidgetThresholdInInputSingularInterface["name"]; ok { @@ -559,11 +559,11 @@ func expandDashboardTableWidgetConfigurationThresholdInput(d *schema.ResourceDat // and assign them to respective attributes of the DashboardTableWidgetThresholdInput object if v, ok := tableWidgetThresholdInInputSingularInterface["from"]; ok { - t := v.(int) + t := v.(float64) tableWidgetThresholdToBeAdded.From = &t } if v, ok := tableWidgetThresholdInInputSingularInterface["to"]; ok { - t := v.(int) + t := v.(float64) tableWidgetThresholdToBeAdded.To = &t } if v, ok := tableWidgetThresholdInInputSingularInterface["column_name"]; ok { diff --git a/website/docs/r/one_dashboard.html.markdown b/website/docs/r/one_dashboard.html.markdown index 41fce844c..1b6e84ac5 100644 --- a/website/docs/r/one_dashboard.html.markdown +++ b/website/docs/r/one_dashboard.html.markdown @@ -115,8 +115,8 @@ resource "newrelic_one_dashboard" "exampledash" { threshold { name = "Duration Threshold Two" - from = 2 - to = 3 + from = 2.1 + to = 3.3 severity = "warning" }