From bda70259d32bb35fbf001adcd8cbf8a32364d233 Mon Sep 17 00:00:00 2001 From: Pete Davids <5599894+MisterSquishy@users.noreply.github.com> Date: Wed, 21 Aug 2024 14:30:51 -0400 Subject: [PATCH] add support for gauge viz type (#233) * allow gauge * added terraform docs --------- Co-authored-by: MisterSquishy --- .go-version | 2 +- docs/resources/alert.md | 4 ++ docs/resources/dashboard.md | 4 ++ lightstep/resource_dashboard.go | 9 +++++ lightstep/resource_dashboard_test.go | 60 ++++++++++++++++++++++++++++ 5 files changed, 78 insertions(+), 1 deletion(-) diff --git a/.go-version b/.go-version index acbb747..783fda8 100644 --- a/.go-version +++ b/.go-version @@ -1 +1 @@ -1.97.0 +1.98.0 diff --git a/docs/resources/alert.md b/docs/resources/alert.md index 71f9ff1..3f25020 100644 --- a/docs/resources/alert.md +++ b/docs/resources/alert.md @@ -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) @@ -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) diff --git a/docs/resources/dashboard.md b/docs/resources/dashboard.md index 79c0d98..3ce082c 100644 --- a/docs/resources/dashboard.md +++ b/docs/resources/dashboard.md @@ -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) @@ -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) diff --git a/lightstep/resource_dashboard.go b/lightstep/resource_dashboard.go index f32424f..c16cc83 100644 --- a/lightstep/resource_dashboard.go +++ b/lightstep/resource_dashboard.go @@ -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 @@ -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.", diff --git a/lightstep/resource_dashboard_test.go b/lightstep/resource_dashboard_test.go index d8ac4f7..b2b403e 100644 --- a/lightstep/resource_dashboard_test.go +++ b/lightstep/resource_dashboard_test.go @@ -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