From e95137468568da1f449dc03d519081b2b230fb53 Mon Sep 17 00:00:00 2001 From: Erik <150863521+erik-snow@users.noreply.github.com> Date: Tue, 4 Jun 2024 13:43:44 -0700 Subject: [PATCH] Add Tricharts (#227) * Add trichart as a display type * Add trichart test --- .go-version | 2 +- DEVELOPMENT.md | 8 +++- lightstep/resource_dashboard.go | 1 + lightstep/resource_dashboard_test.go | 62 ++++++++++++++++++++++++++++ 4 files changed, 70 insertions(+), 3 deletions(-) diff --git a/.go-version b/.go-version index 3495033..69b369b 100644 --- a/.go-version +++ b/.go-version @@ -1 +1 @@ -1.95.4 +1.95.5 diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 41560c1..6434950 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -7,6 +7,9 @@ If you're contributing changes or code to the provider, the integration tests cr To run the tests, first get an API key with a Member role for the public environment and run: ``` +export TF_ACC_PROVIDER_NAMESPACE="hashicorp" +export TF_ACC_PROVIDER_HOST="registry.opentofu.org" +export TF_ACC_TERRAFORM_PATH="$(which terraform)" LIGHTSTEP_API_KEY_PUBLIC=(your api key here) make acc-test ``` @@ -32,8 +35,9 @@ provider_installation { ## Updating docs Documentation files in `docs` are generated by combining: -* the contents of the `.md.tmpl` template files found in the `template` directory -* field-level documentation configured inline via `Description` attributes in `lightstep/*.go`. + +- the contents of the `.md.tmpl` template files found in the `template` directory +- field-level documentation configured inline via `Description` attributes in `lightstep/*.go`. Any edits to documentation files should be made in the `templates` directory or the .go files. Then you can use the following steps to generate the files in the docs directory: diff --git a/lightstep/resource_dashboard.go b/lightstep/resource_dashboard.go index 7ee7bea..45bd33f 100644 --- a/lightstep/resource_dashboard.go +++ b/lightstep/resource_dashboard.go @@ -31,6 +31,7 @@ func getUnifiedQuerySchemaMap() map[string]*schema.Schema { "pie", "table", "traces_list", + "trichart", }, false), }, // See https://github.com/hashicorp/terraform-plugin-sdk/issues/155 diff --git a/lightstep/resource_dashboard_test.go b/lightstep/resource_dashboard_test.go index 5d4287c..d8ac4f7 100644 --- a/lightstep/resource_dashboard_test.go +++ b/lightstep/resource_dashboard_test.go @@ -933,6 +933,59 @@ chart { `, displayType, displayTypeOptions) } +func makeTrichartDisplay() string { + return fmt.Sprintf(` +resource "lightstep_dashboard" "test_display_type_options" { +project_name = "` + testProject + `" +dashboard_name = "test trichart" + +group { +rank = 0 +title = "" +visibility_type = "implicit" + +chart { + name = "Chart #123" + type = "timeseries" + rank = 0 + x_pos = 4 + y_pos = 0 + width = 4 + height = 4 + + query { + query_name = "error_ratio" + display = "trichart" + display_type_options { + display_type = "trichart" + } + hidden = false + query_string = "with\n errors = spans count\n | delta\n | filter service == \"web\" && error == true\n | group_by [], sum;\n total = spans count\n | delta\n | filter service == \"web\"\n | group_by [], sum;\n join errors / total, errors=0, total=0" + } + query { + query_name = "latency" + display = "trichart" + display_type_options { + display_type = "trichart" + } + hidden = false + query_string = "spans latency | delta | filter service == \"web\" | group_by [], sum | point percentile(value, 99.0)" + } + query { + query_name = "rate" + display = "trichart" + display_type_options { + display_type = "trichart" + } + hidden = false + query_string = "spans count | rate | filter service == \"web\" | group_by [], sum" + } + } +} +} +`) +} + func TestDisplayTypeOptionsError(t *testing.T) { var dashboard client.UnifiedDashboard @@ -1062,6 +1115,15 @@ func TestDisplayTypeOptions(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "group.0.chart.0.query.0.display_type_options.0.y_axis_max", "100"), ), }, + { + Config: makeTrichartDisplay(), + Check: resource.ComposeTestCheckFunc( + testAccCheckMetricDashboardExists(resourceName, &dashboard), + resource.TestCheckResourceAttr(resourceName, "dashboard_name", "test trichart"), + resource.TestCheckResourceAttr(resourceName, "group.0.chart.0.query.0.display", "trichart"), + resource.TestCheckResourceAttr(resourceName, "group.0.chart.0.query.0.display_type_options.0.display_type", "trichart"), + ), + }, { Config: makeDisplayTypeConfig("dependency_map", strings.TrimSpace(` display_type_options {