Skip to content

Commit

Permalink
allow gauge
Browse files Browse the repository at this point in the history
  • Loading branch information
MisterSquishy committed Aug 20, 2024
1 parent 2fc3ecf commit 9d88f9e
Show file tree
Hide file tree
Showing 3 changed files with 70 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
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 9d88f9e

Please sign in to comment.