@@ -11,6 +11,15 @@ import (
1111 "github.com/hashicorp/terraform-plugin-sdk/terraform"
1212)
1313
14+ var firstLabelKey = "service"
15+ var secondLabelKey = "env"
16+ var topologyLabel = TopologyLabel {
17+ Data : map [string ][]string {
18+ firstLabelKey : {"collection-proxy" },
19+ secondLabelKey : {"dev" , "prod" },
20+ },
21+ }
22+
1423func TestAccSumologicDashboard_basic (t * testing.T ) {
1524 testNameSuffix := acctest .RandString (16 )
1625 title := "terraform_test_dashboard_" + testNameSuffix
@@ -41,8 +50,7 @@ func TestAccSumologicDashboard_create(t *testing.T) {
4150 description := "Test dashboard description"
4251 theme := "Dark"
4352 refreshInterval := 120
44- topologyLabel := "service"
45- topologyLabelValue := "collection-proxy"
53+ domain := "aws"
4654 literalRangeName := "today"
4755 textPanel := TextPanel {
4856 Key : "text-panel-001" ,
@@ -77,7 +85,7 @@ func TestAccSumologicDashboard_create(t *testing.T) {
7785 Steps : []resource.TestStep {
7886 {
7987 Config : dashboardCreateConfig (title , description , theme , refreshInterval ,
80- topologyLabel , topologyLabelValue , literalRangeName , textPanel , layout , variable ),
88+ topologyLabel , domain , literalRangeName , textPanel , layout , variable ),
8189 Check : resource .ComposeTestCheckFunc (
8290 testAccCheckDashboardExists ("sumologic_dashboard.tf_crud_test" , & dashboard , t ),
8391 resource .TestCheckResourceAttr ("sumologic_dashboard.tf_crud_test" ,
@@ -89,9 +97,9 @@ func TestAccSumologicDashboard_create(t *testing.T) {
8997 resource .TestCheckResourceAttr ("sumologic_dashboard.tf_crud_test" ,
9098 "theme" , theme ),
9199 resource .TestCheckResourceAttr ("sumologic_dashboard.tf_crud_test" ,
92- "topology_label_map.0.data.0.label " , topologyLabel ),
100+ "topology_label_map.0.data.# " , "2" ),
93101 resource .TestCheckResourceAttr ("sumologic_dashboard.tf_crud_test" ,
94- "topology_label_map.0.data.0.values.0 " , topologyLabelValue ),
102+ "domain " , domain ),
95103 resource .TestCheckResourceAttr ("sumologic_dashboard.tf_crud_test" ,
96104 "time_range.#" , "1" ),
97105 resource .TestCheckResourceAttr ("sumologic_dashboard.tf_crud_test" ,
@@ -124,8 +132,7 @@ func TestAccSumologicDashboard_update(t *testing.T) {
124132 description := "Test dashboard description"
125133 theme := "Dark"
126134 refreshInterval := 120
127- topologyLabel := "service"
128- topologyLabelValue := "collection-proxy"
135+ domain := "aws"
129136 literalRangeName := "today"
130137 textPanel := TextPanel {
131138 Key : "text-panel-001" ,
@@ -155,7 +162,8 @@ func TestAccSumologicDashboard_update(t *testing.T) {
155162 // updated config
156163 newTheme := "Light"
157164 newRefreshInterval := 300
158- newTopologyLabelValue := "collection-cluster"
165+ newFirstLabelValue := "collection-cluster"
166+ updatedDomain := "app"
159167 newLiteralRangeName := "week"
160168 searchPanel := SumoSearchPanel {
161169 Key : "search-panel-001" ,
@@ -207,7 +215,7 @@ func TestAccSumologicDashboard_update(t *testing.T) {
207215 Steps : []resource.TestStep {
208216 {
209217 Config : dashboardCreateConfig (title , description , theme , refreshInterval ,
210- topologyLabel , topologyLabelValue , literalRangeName , textPanel , layout , csvVariable ),
218+ topologyLabel , domain , literalRangeName , textPanel , layout , csvVariable ),
211219 Check : resource .ComposeTestCheckFunc (
212220 testAccCheckDashboardExists ("sumologic_dashboard.tf_crud_test" , & dashboard , t ),
213221 resource .TestCheckResourceAttr ("sumologic_dashboard.tf_crud_test" ,
@@ -217,7 +225,9 @@ func TestAccSumologicDashboard_update(t *testing.T) {
217225 resource .TestCheckResourceAttr ("sumologic_dashboard.tf_crud_test" ,
218226 "theme" , theme ),
219227 resource .TestCheckResourceAttr ("sumologic_dashboard.tf_crud_test" ,
220- "topology_label_map.0.data.0.values.0" , topologyLabelValue ),
228+ "topology_label_map.0.data.#" , "2" ),
229+ resource .TestCheckResourceAttr ("sumologic_dashboard.tf_crud_test" ,
230+ "domain" , domain ),
221231 resource .TestCheckResourceAttr ("sumologic_dashboard.tf_crud_test" ,
222232 "time_range.0.begin_bounded_time_range.0.from.0.literal_time_range.0.range_name" ,
223233 literalRangeName ),
@@ -237,8 +247,8 @@ func TestAccSumologicDashboard_update(t *testing.T) {
237247 },
238248 {
239249 Config : dashboardUpdateConfig (title , description , newTheme , newRefreshInterval ,
240- topologyLabel , newTopologyLabelValue , newLiteralRangeName , textPanel , searchPanel ,
241- newLayout , newVariables ),
250+ firstLabelKey , newFirstLabelValue , updatedDomain , newLiteralRangeName , textPanel ,
251+ searchPanel , newLayout , newVariables ),
242252 Check : resource .ComposeTestCheckFunc (
243253 testAccCheckDashboardExists ("sumologic_dashboard.tf_crud_test" , & dashboard , t ),
244254 resource .TestCheckResourceAttr ("sumologic_dashboard.tf_crud_test" ,
@@ -248,7 +258,9 @@ func TestAccSumologicDashboard_update(t *testing.T) {
248258 resource .TestCheckResourceAttr ("sumologic_dashboard.tf_crud_test" ,
249259 "theme" , newTheme ),
250260 resource .TestCheckResourceAttr ("sumologic_dashboard.tf_crud_test" ,
251- "topology_label_map.0.data.0.values.0" , newTopologyLabelValue ),
261+ "topology_label_map.0.data.#" , "1" ),
262+ resource .TestCheckResourceAttr ("sumologic_dashboard.tf_crud_test" ,
263+ "domain" , updatedDomain ),
252264 resource .TestCheckResourceAttr ("sumologic_dashboard.tf_crud_test" ,
253265 "time_range.0.begin_bounded_time_range.0.from.0.literal_time_range.0.range_name" ,
254266 newLiteralRangeName ),
@@ -391,7 +403,7 @@ func dashboardImportConfig(title string) string {
391403}
392404
393405func dashboardCreateConfig (title string , description string , theme string , refreshInterval int ,
394- topologyLabel string , topologyLabelValue string , rangeName string , textPanel TextPanel ,
406+ topologyLabel TopologyLabel , domain string , rangeName string , textPanel TextPanel ,
395407 layout GridLayout , variable Variable ) string {
396408
397409 return fmt .Sprintf (`
@@ -407,7 +419,12 @@ func dashboardCreateConfig(title string, description string, theme string, refre
407419 label = "%s"
408420 values = ["%s"]
409421 }
422+ data {
423+ label = "%s"
424+ values = ["%s", "%s"]
425+ }
410426 }
427+ domain = "%s"
411428 time_range {
412429 begin_bounded_time_range {
413430 from {
@@ -448,16 +465,18 @@ func dashboardCreateConfig(title string, description string, theme string, refre
448465 hide_from_ui = false
449466 }
450467 }` ,
451- title , description , refreshInterval , theme , topologyLabel , topologyLabelValue , rangeName ,
452- textPanel .Key , textPanel .Title , textPanel .Text ,
468+ title , description , refreshInterval , theme , firstLabelKey , topologyLabel .Data [firstLabelKey ][0 ],
469+ secondLabelKey , topologyLabel .Data [secondLabelKey ][0 ], topologyLabel .Data [secondLabelKey ][1 ],
470+ domain , rangeName , textPanel .Key , textPanel .Title , textPanel .Text ,
453471 layout .LayoutStructures [0 ].Key , variable .Name , variable .DisplayName , variable .DefaultValue ,
454472 variable .SourceDefinition .(CsvVariableSourceDefinition ).Values ,
455473 )
456474}
457475
458476func dashboardUpdateConfig (title string , description string , theme string , refreshInterval int ,
459- topologyLabel string , topologyLabelValue string , rangeName string , textPanel TextPanel ,
460- searchPanel SumoSearchPanel , layout GridLayout , variables []Variable ) string {
477+ topologyLabel string , topologyLabelValue string , domain string , rangeName string ,
478+ textPanel TextPanel , searchPanel SumoSearchPanel , layout GridLayout ,
479+ variables []Variable ) string {
461480
462481 loqQuerySourceDef := variables [1 ].SourceDefinition .(LogQueryVariableSourceDefinition )
463482 csvSourceDef := variables [0 ].SourceDefinition .(CsvVariableSourceDefinition )
@@ -476,6 +495,7 @@ func dashboardUpdateConfig(title string, description string, theme string, refre
476495 values = ["%s"]
477496 }
478497 }
498+ domain = "%s"
479499 time_range {
480500 begin_bounded_time_range {
481501 from {
@@ -558,8 +578,8 @@ func dashboardUpdateConfig(title string, description string, theme string, refre
558578 hide_from_ui = false
559579 }
560580 }` ,
561- title , description , refreshInterval , theme , topologyLabel , topologyLabelValue , rangeName ,
562- textPanel .Key , textPanel .Title , textPanel .Text ,
581+ title , description , refreshInterval , theme , topologyLabel , topologyLabelValue , domain ,
582+ rangeName , textPanel .Key , textPanel .Title , textPanel .Text ,
563583 searchPanel .Key , searchPanel .Title , searchPanel .Description , searchPanel .Queries [0 ].QueryString ,
564584 searchPanel .Queries [0 ].QueryKey ,
565585 layout .LayoutStructures [0 ].Key , layout .LayoutStructures [1 ].Key ,
0 commit comments