From 885307537a86dcc833987fc05708da13905c02fa Mon Sep 17 00:00:00 2001 From: Pete Davids <5599894+MisterSquishy@users.noreply.github.com> Date: Mon, 12 Feb 2024 17:19:17 -0500 Subject: [PATCH] `tql-query` => `query-string` (#210) * query-string * version * no changes * ok --- .github/workflows/pr.yml | 14 +++++++++----- .go-version | 2 +- client/metric_conditions.go | 2 +- exporter/exporter.go | 8 ++++---- exporter/exporter_test.go | 2 +- lightstep/legacy_query_equivalence.go | 4 ++-- lightstep/resource_alert.go | 2 +- lightstep/resource_dashboard.go | 2 +- lightstep/resource_metric_condition.go | 4 ++-- 9 files changed, 22 insertions(+), 18 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 6d87731d..79d2cd7e 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -57,11 +57,15 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - git config --local user.email "${{ github.actor }}@users.noreply.github.com" - git config --local user.name ${{ github.actor }} - git add . - git commit -m "added terraform docs" - git push + if [[ `git status --porcelain` ]]; then + git config --local user.email "${{ github.actor }}@users.noreply.github.com" + git config --local user.name ${{ github.actor }} + git add . + git commit -m "added terraform docs" + git push + else + echo "no changes" + fi terraform_lint: diff --git a/.go-version b/.go-version index 9a5d24e6..8a78acff 100644 --- a/.go-version +++ b/.go-version @@ -1,2 +1,2 @@ -1.91.0 +1.91.1 diff --git a/client/metric_conditions.go b/client/metric_conditions.go index 5454d80b..131f5663 100644 --- a/client/metric_conditions.go +++ b/client/metric_conditions.go @@ -75,7 +75,7 @@ type MetricQueryWithAttributes struct { Query MetricQuery `json:"metric-query"` SpansQuery SpansQuery `json:"spans-query,omitempty"` CompositeQuery CompositeQuery `json:"composite-query,omitempty"` - TQLQuery string `json:"tql-query"` + QueryString string `json:"query-string"` DependencyMapOptions *DependencyMapOptions `json:"dependency-map-options,omitempty"` HiddenQueries map[string]bool `json:"hidden-queries,omitempty"` } diff --git a/exporter/exporter.go b/exporter/exporter.go index 70f141a0..2cca3a9d 100644 --- a/exporter/exporter.go +++ b/exporter/exporter.go @@ -34,8 +34,8 @@ resource "lightstep_metric_dashboard" "exported_dashboard" { group_by_keys = [{{range .SpansQuery.GroupByKeys}}"{{.}}",{{end}}]{{if eq .SpansQuery.Operator "latency"}} latency_percentiles = [{{range .SpansQuery.LatencyPercentiles}}{{.}},{{end}}]{{end}} } -{{end}}{{if .TQLQuery}} - tql = {{escapeHeredocString .TQLQuery}} +{{end}}{{if .QueryString}} + tql = {{escapeHeredocString .QueryString}} {{end}}{{if .Query.Metric}} metric = "{{.Query.Metric}}" timeseries_operator = "{{.Query.TimeseriesOperator}}" @@ -75,7 +75,7 @@ resource "lightstep_dashboard" "exported_dashboard" { query_name = "{{.Name}}" display = "{{.Display}}" hidden = {{.Hidden}} - query_string = {{escapeHeredocString .TQLQuery}} + query_string = {{escapeHeredocString .QueryString}} {{- if .DependencyMapOptions}} dependency_map_options { scope = "{{.DependencyMapOptions.Scope}}" @@ -124,7 +124,7 @@ func dashboardUsesLegacyQuery(d *client.UnifiedDashboard) bool { // Assume if a chart is defined but has query string defined, it uses a legacy query. This // isn't strictly correct if the chart has *no* query but a chart with no query is not // meaningful to begin with. - if len(q.TQLQuery) == 0 { + if len(q.QueryString) == 0 { return true } } diff --git a/exporter/exporter_test.go b/exporter/exporter_test.go index 16d492dc..f5637e19 100644 --- a/exporter/exporter_test.go +++ b/exporter/exporter_test.go @@ -86,7 +86,7 @@ EOT`, Name: "my_query", Display: "line", Hidden: false, - TQLQuery: testCase.QueryString, + QueryString: testCase.QueryString, DependencyMapOptions: testCase.DependencyMapOptions, }, }, diff --git a/lightstep/legacy_query_equivalence.go b/lightstep/legacy_query_equivalence.go index d709e901..277cea0d 100644 --- a/lightstep/legacy_query_equivalence.go +++ b/lightstep/legacy_query_equivalence.go @@ -125,7 +125,7 @@ func compareUpdatedLegacyQueries( if len(priorQueries) == len(updatedQueries) && hasOnlyTQLQueries(priorQueries) && hasOnlyTQLQueries(updatedQueries) { for i, pq := range priorQueries { - if pq.TQLQuery != updatedQueries[i].TQLQuery { + if pq.QueryString != updatedQueries[i].QueryString { return false, nil } } @@ -165,7 +165,7 @@ func compareUpdatedLegacyQueries( if q.Type != "tql" { return false, nil } - updatedUQL[simplifyQueryName(q.Name)] = q.TQLQuery + updatedUQL[simplifyQueryName(q.Name)] = q.QueryString } // Step 3: compare the queries are equivalent diff --git a/lightstep/resource_alert.go b/lightstep/resource_alert.go index b94e9dcf..3f7fb925 100644 --- a/lightstep/resource_alert.go +++ b/lightstep/resource_alert.go @@ -38,7 +38,7 @@ func getQueriesFromUnifiedConditionResourceData( "hidden": q.Hidden, "display": q.Display, "query_name": q.Name, - "query_string": q.TQLQuery, + "query_string": q.QueryString, } queries = append(queries, qs) } diff --git a/lightstep/resource_dashboard.go b/lightstep/resource_dashboard.go index b6b778d5..5451b07d 100644 --- a/lightstep/resource_dashboard.go +++ b/lightstep/resource_dashboard.go @@ -134,7 +134,7 @@ func getQueriesFromUnifiedDashboardResourceData( "display": q.Display, "display_type_options": convertNestedMapToSchemaSet(q.DisplayTypeOptions), "query_name": q.Name, - "query_string": q.TQLQuery, + "query_string": q.QueryString, "dependency_map_options": getDependencyMapOptions(q.DependencyMapOptions), } if len(q.HiddenQueries) > 0 { diff --git a/lightstep/resource_metric_condition.go b/lightstep/resource_metric_condition.go index 3e6e7d69..89714323 100644 --- a/lightstep/resource_metric_condition.go +++ b/lightstep/resource_metric_condition.go @@ -824,7 +824,7 @@ func buildQueries(queriesIn []interface{}) ([]client.MetricQueryWithAttributes, Type: "tql", Hidden: query["hidden"].(bool), Display: query["display"].(string), - TQLQuery: queryString, + QueryString: queryString, DependencyMapOptions: buildDependencyMapOptions(query["dependency_map_options"]), } @@ -1427,7 +1427,7 @@ func getQueriesFromMetricConditionData(queriesIn []client.MetricQueryWithAttribu "exclude_filters": excludeFilters, "filters": allFilters, "group_by": groupBy, - "tql": q.TQLQuery, // deprecated + "tql": q.QueryString, } if q.Query.TimeseriesOperatorInputWindowMs != nil { qs["timeseries_operator_input_window_ms"] = *q.Query.TimeseriesOperatorInputWindowMs