Skip to content

Commit

Permalink
add support for gauge viz type (#233)
Browse files Browse the repository at this point in the history
* allow gauge

* added terraform docs

---------

Co-authored-by: MisterSquishy <[email protected]>
  • Loading branch information
MisterSquishy and MisterSquishy authored Aug 21, 2024
1 parent 2fc3ecf commit bda7025
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .go-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.97.0
1.98.0
4 changes: 4 additions & 0 deletions docs/resources/alert.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ Optional:
- `comparison_window_ms` (Number)
- `display_type` (String)
- `is_donut` (Boolean)
- `max` (Number)
- `min` (Number)
- `sort_by` (String)
- `sort_direction` (String)
- `y_axis_log_base` (Number)
Expand Down Expand Up @@ -278,6 +280,8 @@ Optional:
- `comparison_window_ms` (Number)
- `display_type` (String)
- `is_donut` (Boolean)
- `max` (Number)
- `min` (Number)
- `sort_by` (String)
- `sort_direction` (String)
- `y_axis_log_base` (Number)
Expand Down
4 changes: 4 additions & 0 deletions docs/resources/dashboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ Optional:
- `comparison_window_ms` (Number)
- `display_type` (String)
- `is_donut` (Boolean)
- `max` (Number)
- `min` (Number)
- `sort_by` (String)
- `sort_direction` (String)
- `y_axis_log_base` (Number)
Expand Down Expand Up @@ -314,6 +316,8 @@ Optional:
- `comparison_window_ms` (Number)
- `display_type` (String)
- `is_donut` (Boolean)
- `max` (Number)
- `min` (Number)
- `sort_by` (String)
- `sort_direction` (String)
- `y_axis_log_base` (Number)
Expand Down
9 changes: 9 additions & 0 deletions lightstep/resource_dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func getUnifiedQuerySchemaMap() map[string]*schema.Schema {
"table",
"traces_list",
"trichart",
"gauge",
}, false),
},
// See https://github.com/hashicorp/terraform-plugin-sdk/issues/155
Expand Down Expand Up @@ -116,6 +117,14 @@ func getUnifiedQuerySchemaMap() map[string]*schema.Schema {
Type: schema.TypeInt,
Optional: true,
},
"min": {
Type: schema.TypeInt,
Optional: true,
},
"max": {
Type: schema.TypeInt,
Optional: true,
},
},
},
Description: "Applicable options vary depending on the display type. Please see the Lightstep documentation for a full description.",
Expand Down
60 changes: 60 additions & 0 deletions lightstep/resource_dashboard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1498,6 +1498,66 @@ group {
})
}

func TestGauge(t *testing.T) {
var dashboard client.UnifiedDashboard

resourceName := "lightstep_dashboard.test_gauge"

configTemplate := `
resource "lightstep_dashboard" "test_gauge" {
project_name = "` + testProject + `"
dashboard_name = "test gauges"
group {
rank = 0
title = ""
visibility_type = "implicit"
chart {
name = "overall cpu utilization"
type = "timeseries"
rank = 0
x_pos = 4
y_pos = 0
width = 4
height = 4
query {
query_name = "a"
display = "gauge"
hidden = false
query_string = "metric cpu.utilization | delta | group_by[], sum"
display_type_options {
min = 0
max = 100
}
}
}
}
}
`

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testGetMetricDashboardDestroy,
Steps: []resource.TestStep{
{
Config: configTemplate,
Check: resource.ComposeTestCheckFunc(
testAccCheckMetricDashboardExists(resourceName, &dashboard),
resource.TestCheckResourceAttr(resourceName, "group.#", "1"),
resource.TestCheckResourceAttr(resourceName, "group.0.chart.#", "1"),
resource.TestCheckResourceAttr(resourceName, "group.0.chart.0.query.#", "1"),
resource.TestCheckResourceAttr(resourceName, "group.0.chart.0.query.0.display", "gauge"),
resource.TestCheckResourceAttr(resourceName, "group.0.chart.0.query.0.display_type_options.0.min", "0"),
resource.TestCheckResourceAttr(resourceName, "group.0.chart.0.query.0.display_type_options.0.max", "100"),
),
},
},
})
}

func TestValidationErrors(t *testing.T) {
var dashboard client.UnifiedDashboard

Expand Down

0 comments on commit bda7025

Please sign in to comment.