Skip to content

Commit 64a5773

Browse files
committed
Use Set type for topology label to avoid ordering issues
1 parent 353339d commit 64a5773

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

sumologic/resource_sumologic_dashboard.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func resourceSumologicDashboard() *schema.Resource {
6969
Elem: &schema.Resource{
7070
Schema: map[string]*schema.Schema{
7171
"data": {
72-
Type: schema.TypeList,
72+
Type: schema.TypeSet,
7373
Required: true,
7474
Elem: &schema.Resource{
7575
Schema: map[string]*schema.Schema{
@@ -948,9 +948,9 @@ func getTimeRangeBoundary(tfRangeBoundary map[string]interface{}) interface{} {
948948
}
949949

950950
func getTopologyLabel(tfTopologyLabel map[string]interface{}) *TopologyLabel {
951-
if items := tfTopologyLabel["data"].([]interface{}); len(items) >= 1 {
951+
if items := tfTopologyLabel["data"].(*schema.Set); items.Len() >= 1 {
952952
labelMap := make(map[string][]string)
953-
for _, item := range items {
953+
for _, item := range items.List() {
954954
dataItem := item.(map[string]interface{})
955955
key := dataItem["label"].(string)
956956
itemValues := dataItem["values"].([]interface{})
@@ -960,6 +960,7 @@ func getTopologyLabel(tfTopologyLabel map[string]interface{}) *TopologyLabel {
960960
}
961961
labelMap[key] = values
962962
}
963+
963964
return &TopologyLabel{
964965
Data: labelMap,
965966
}

sumologic/resource_sumologic_dashboard_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,6 @@ func TestAccSumologicDashboard_update(t *testing.T) {
253253
"theme", newTheme),
254254
resource.TestCheckResourceAttr("sumologic_dashboard.tf_crud_test",
255255
"topology_label_map.0.data.#", "1"),
256-
resource.TestCheckResourceAttr("sumologic_dashboard.tf_crud_test",
257-
"topology_label_map.0.data.0.label", firstLabelKey),
258-
resource.TestCheckResourceAttr("sumologic_dashboard.tf_crud_test",
259-
"topology_label_map.0.data.0.values.0", newFirstLabelValue),
260256
resource.TestCheckResourceAttr("sumologic_dashboard.tf_crud_test",
261257
"time_range.0.begin_bounded_time_range.0.from.0.literal_time_range.0.range_name",
262258
newLiteralRangeName),

sumologic/sumologic_dashboard.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package sumologic
33
import (
44
"encoding/json"
55
"fmt"
6+
"log"
67
)
78

89
func (s *Client) GetDashboard(id string) (*Dashboard, error) {
@@ -20,6 +21,7 @@ func (s *Client) GetDashboard(id string) (*Dashboard, error) {
2021
if err != nil {
2122
return nil, err
2223
}
24+
log.Printf("[GetDashboard] response: %+v\n", dashboard)
2325
return &dashboard, nil
2426
}
2527

@@ -34,6 +36,7 @@ func (s *Client) CreateDashboard(dashboardReq Dashboard) (*Dashboard, error) {
3436
if err != nil {
3537
return nil, err
3638
}
39+
log.Printf("[CreateDashboard] response: %+v\n", dashboard)
3740
return &dashboard, nil
3841
}
3942

0 commit comments

Comments
 (0)