From b43341a4b162940d878e40f80d511a1b288f78f4 Mon Sep 17 00:00:00 2001 From: Pete Davids <5599894+MisterSquishy@users.noreply.github.com> Date: Wed, 4 Sep 2024 12:15:46 -0400 Subject: [PATCH] allow "auto" setting for gauge min and max (#234) * auto * added terraform docs --------- Co-authored-by: MisterSquishy --- .go-version | 2 +- docs/resources/alert.md | 8 ++++---- docs/resources/dashboard.md | 8 ++++---- lightstep/resource_dashboard.go | 11 +++++++---- lightstep/resource_dashboard_test.go | 4 ++-- 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/.go-version b/.go-version index 783fda8..5c87d60 100644 --- a/.go-version +++ b/.go-version @@ -1 +1 @@ -1.98.0 +1.98.1 diff --git a/docs/resources/alert.md b/docs/resources/alert.md index 3f25020..26f12c4 100644 --- a/docs/resources/alert.md +++ b/docs/resources/alert.md @@ -209,8 +209,8 @@ Optional: - `comparison_window_ms` (Number) - `display_type` (String) - `is_donut` (Boolean) -- `max` (Number) -- `min` (Number) +- `max` (String) +- `min` (String) - `sort_by` (String) - `sort_direction` (String) - `y_axis_log_base` (Number) @@ -280,8 +280,8 @@ Optional: - `comparison_window_ms` (Number) - `display_type` (String) - `is_donut` (Boolean) -- `max` (Number) -- `min` (Number) +- `max` (String) +- `min` (String) - `sort_by` (String) - `sort_direction` (String) - `y_axis_log_base` (Number) diff --git a/docs/resources/dashboard.md b/docs/resources/dashboard.md index 3ce082c..d543076 100644 --- a/docs/resources/dashboard.md +++ b/docs/resources/dashboard.md @@ -137,8 +137,8 @@ Optional: - `comparison_window_ms` (Number) - `display_type` (String) - `is_donut` (Boolean) -- `max` (Number) -- `min` (Number) +- `max` (String) +- `min` (String) - `sort_by` (String) - `sort_direction` (String) - `y_axis_log_base` (Number) @@ -316,8 +316,8 @@ Optional: - `comparison_window_ms` (Number) - `display_type` (String) - `is_donut` (Boolean) -- `max` (Number) -- `min` (Number) +- `max` (String) +- `min` (String) - `sort_by` (String) - `sort_direction` (String) - `y_axis_log_base` (Number) diff --git a/lightstep/resource_dashboard.go b/lightstep/resource_dashboard.go index c16cc83..3c0742f 100644 --- a/lightstep/resource_dashboard.go +++ b/lightstep/resource_dashboard.go @@ -2,6 +2,7 @@ package lightstep import ( "fmt" + "regexp" "github.com/lightstep/terraform-provider-lightstep/client" @@ -118,12 +119,14 @@ func getUnifiedQuerySchemaMap() map[string]*schema.Schema { Optional: true, }, "min": { - Type: schema.TypeInt, - Optional: true, + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^(\d|\.)*$`), ""), }, "max": { - Type: schema.TypeInt, - Optional: true, + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^(\d|\.)*$`), ""), }, }, }, diff --git a/lightstep/resource_dashboard_test.go b/lightstep/resource_dashboard_test.go index b2b403e..18dbf72 100644 --- a/lightstep/resource_dashboard_test.go +++ b/lightstep/resource_dashboard_test.go @@ -1529,7 +1529,7 @@ group { query_string = "metric cpu.utilization | delta | group_by[], sum" display_type_options { min = 0 - max = 100 + max = "" } } } @@ -1551,7 +1551,7 @@ group { 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"), + resource.TestCheckResourceAttr(resourceName, "group.0.chart.0.query.0.display_type_options.0.max", ""), ), }, },