Skip to content

Commit

Permalink
fix(dashboard): update line and table widget threshold to and `from…
Browse files Browse the repository at this point in the history
…` datatype (#2713)

Co-authored-by: pranav-new-relic <[email protected]>
  • Loading branch information
vagrawal-newrelic and pranav-new-relic authored Jul 17, 2024
1 parent db48a0b commit 928e545
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 17 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
8 changes: 4 additions & 4 deletions newrelic/resource_newrelic_one_dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
},
Expand Down Expand Up @@ -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.",
},
Expand Down
20 changes: 16 additions & 4 deletions newrelic/resource_newrelic_one_dashboard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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"
}
Expand Down Expand Up @@ -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"
}
Expand Down Expand Up @@ -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"]
}
Expand Down
8 changes: 4 additions & 4 deletions newrelic/structures_newrelic_one_dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions website/docs/r/one_dashboard.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down

0 comments on commit 928e545

Please sign in to comment.