Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix unresolvable hidden_queries diff #224

Merged
merged 2 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .go-version
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
1.95.1

1.95.2
9 changes: 5 additions & 4 deletions lightstep/resource_dashboard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1482,7 +1482,7 @@ EOT
})
}

func TestAccDashboardHiddenQueriesUnresolvableDiff(t *testing.T) {
func TestAccDashboardHiddenQueriesWithOuterQueryHidden(t *testing.T) {
config := `
resource "lightstep_dashboard" "test" {
project_name = "` + testProject + `"
Expand Down Expand Up @@ -1514,10 +1514,11 @@ resource "lightstep_dashboard" "test" {
Config: config,
Check: resource.ComposeTestCheckFunc(
testAccCheckMetricDashboardExists(resourceName, &dashboard),
resource.TestCheckResourceAttr(resourceName, "chart.#", "1"),
resource.TestCheckResourceAttr(resourceName, "chart.0.query.#", "1"),
resource.TestCheckResourceAttr(resourceName, "chart.0.query.0.hidden", "false"),
resource.TestCheckResourceAttr(resourceName, "chart.0.query.0.hidden_queries.a", "true"),
),
// 🐛 this plan should be empty, but we omit hidden_queries["a"] from state
// because it is the top level query name (also we overwrite the value using "hidden")
ExpectNonEmptyPlan: true,
},
},
})
Expand Down
3 changes: 0 additions & 3 deletions lightstep/resource_metric_condition.go
Original file line number Diff line number Diff line change
Expand Up @@ -836,9 +836,6 @@ func buildQueries(queriesIn []interface{}) ([]client.MetricQueryWithAttributes,
hq[k] = false
}
}
// Ensure the outer query is always included for the API call.
// Don't make the user do this explicitly.
hq[newQuery.Name] = newQuery.Hidden
newQuery.HiddenQueries = hq
}

Expand Down
4 changes: 0 additions & 4 deletions lightstep/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ func setHiddenQueriesFromResourceData(qs map[string]interface{}, query client.Me
}
hq := make(map[string]interface{}, len(query.HiddenQueries))
for k, v := range query.HiddenQueries {
// Don't include the top-level query in the TF resource data
if k == query.Name {
continue
}
hq[k] = fmt.Sprintf("%t", v)
}
qs["hidden_queries"] = hq
Expand Down
Loading