Skip to content

Commit

Permalink
fix unresolvable hidden_queries diff (#224)
Browse files Browse the repository at this point in the history
* fix?

* no stoppp
  • Loading branch information
MisterSquishy authored May 23, 2024
1 parent 6c548e1 commit d858e7a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 13 deletions.
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

0 comments on commit d858e7a

Please sign in to comment.