Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for gauge viz type #233

Merged
merged 2 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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