Skip to content

Commit 3325f20

Browse files
sidharth-chauhanstephan-rayner
authored andcommitted
fix(oncall): make labels/dynamic_labels order-insensitive (#2169)
1 parent 572abdb commit 3325f20

File tree

2 files changed

+1
-6
lines changed

2 files changed

+1
-6
lines changed

internal/resources/oncall/resource_integration.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,6 @@ func resourceIntegration() *common.Resource {
224224
return false
225225
}
226226
for k, v := range oldTemplateMap {
227-
// Convert everything to string to be able to compare across types.
228-
// We're only interested in the actual value here,
229-
// and Terraform will implicitly convert a string to a number, and vice versa.
230227
if fmt.Sprintf("%v", newTemplateMap[k]) != fmt.Sprintf("%v", v) {
231228
return false
232229
}
@@ -855,7 +852,7 @@ func flattenDefaultRoute(in *onCallAPI.DefaultRoute, d *schema.ResourceData) []m
855852
out := make(map[string]any)
856853
out["id"] = in.ID
857854
out["escalation_chain_id"] = in.EscalationChainId
858-
// Set messengers data only if related fields are present
855+
859856
_, slackOk := d.GetOk("default_route.0.slack")
860857
if slackOk && in.SlackRoute != nil {
861858
out["slack"] = flattenRouteSlack(in.SlackRoute)
@@ -933,7 +930,6 @@ func flattenLabels(labels []*onCallAPI.Label) []map[string]string {
933930
})
934931
}
935932

936-
// deterministic ordering to avoid permadiffs when API returns labels in arbitrary order
937933
sort.Slice(flattenedLabels, func(i, j int) bool {
938934
if flattenedLabels[i]["key"] == flattenedLabels[j]["key"] {
939935
return flattenedLabels[i]["value"] < flattenedLabels[j]["value"]

internal/resources/oncall/resource_integration_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ data "grafana_oncall_label" "test-acc-integration-label" {
138138
}
139139
`
140140

141-
// Use object for label, not bare list
142141
return datasource + testAccOnCallIntegrationConfig(rName, rType, `
143142
labels = [{
144143
key = data.grafana_oncall_label.test-acc-integration-label.key

0 commit comments

Comments
 (0)