Skip to content

Commit e8fa7b4

Browse files
authored
Merge pull request #341 from SumoLogic/vishal-add-domain-field
2 parents a531368 + b8254ce commit e8fa7b4

File tree

4 files changed

+39
-15
lines changed

4 files changed

+39
-15
lines changed

sumologic/resource_sumologic_dashboard.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ func resourceSumologicDashboard() *schema.Resource {
9191
},
9292
},
9393
},
94+
"domain": {
95+
Type: schema.TypeString,
96+
Optional: true,
97+
},
9498
"refresh_interval": {
9599
Type: schema.TypeInt,
96100
Optional: true,
@@ -705,6 +709,7 @@ func resourceToDashboard(d *schema.ResourceData) Dashboard {
705709
Description: d.Get("description").(string),
706710
FolderId: d.Get("folder_id").(string),
707711
TopologyLabelMap: topologyLabel,
712+
Domain: d.Get("domain").(string),
708713
RefreshInterval: d.Get("refresh_interval").(int),
709714
TimeRange: timeRange,
710715
Panels: panels,
@@ -1102,6 +1107,9 @@ func setDashboard(d *schema.ResourceData, dashboard *Dashboard) error {
11021107
if err := d.Set("folder_id", dashboard.FolderId); err != nil {
11031108
return err
11041109
}
1110+
if err := d.Set("domain", dashboard.Domain); err != nil {
1111+
return err
1112+
}
11051113
if err := d.Set("refresh_interval", dashboard.RefreshInterval); err != nil {
11061114
return err
11071115
}
@@ -1140,10 +1148,11 @@ func setDashboard(d *schema.ResourceData, dashboard *Dashboard) error {
11401148
}
11411149

11421150
log.Println("=====================================================================")
1143-
log.Printf("title: %+v\n", d.Get("title"))
1144-
log.Printf("description: %+v\n", d.Get("description"))
1145-
log.Printf("folder_id: %+v\n", d.Get("folder_id"))
1151+
log.Printf("title: %s\n", d.Get("title"))
1152+
log.Printf("description: %s\n", d.Get("description"))
1153+
log.Printf("folder_id: %s\n", d.Get("folder_id"))
11461154
log.Printf("topology_label_map: %+v\n", d.Get("topology_label_map"))
1155+
log.Printf("domain: %s\n", d.Get("domain"))
11471156
log.Printf("time_range: %+v\n", d.Get("time_range"))
11481157
log.Printf("panel: %+v\n", d.Get("panel"))
11491158
log.Printf("layout: %+v\n", d.Get("layout"))

sumologic/resource_sumologic_dashboard_test.go

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func TestAccSumologicDashboard_create(t *testing.T) {
5050
description := "Test dashboard description"
5151
theme := "Dark"
5252
refreshInterval := 120
53-
53+
domain := "aws"
5454
literalRangeName := "today"
5555
textPanel := TextPanel{
5656
Key: "text-panel-001",
@@ -85,7 +85,7 @@ func TestAccSumologicDashboard_create(t *testing.T) {
8585
Steps: []resource.TestStep{
8686
{
8787
Config: dashboardCreateConfig(title, description, theme, refreshInterval,
88-
topologyLabel, literalRangeName, textPanel, layout, variable),
88+
topologyLabel, domain, literalRangeName, textPanel, layout, variable),
8989
Check: resource.ComposeTestCheckFunc(
9090
testAccCheckDashboardExists("sumologic_dashboard.tf_crud_test", &dashboard, t),
9191
resource.TestCheckResourceAttr("sumologic_dashboard.tf_crud_test",
@@ -98,6 +98,8 @@ func TestAccSumologicDashboard_create(t *testing.T) {
9898
"theme", theme),
9999
resource.TestCheckResourceAttr("sumologic_dashboard.tf_crud_test",
100100
"topology_label_map.0.data.#", "2"),
101+
resource.TestCheckResourceAttr("sumologic_dashboard.tf_crud_test",
102+
"domain", domain),
101103
resource.TestCheckResourceAttr("sumologic_dashboard.tf_crud_test",
102104
"time_range.#", "1"),
103105
resource.TestCheckResourceAttr("sumologic_dashboard.tf_crud_test",
@@ -130,6 +132,7 @@ func TestAccSumologicDashboard_update(t *testing.T) {
130132
description := "Test dashboard description"
131133
theme := "Dark"
132134
refreshInterval := 120
135+
domain := "aws"
133136
literalRangeName := "today"
134137
textPanel := TextPanel{
135138
Key: "text-panel-001",
@@ -160,6 +163,7 @@ func TestAccSumologicDashboard_update(t *testing.T) {
160163
newTheme := "Light"
161164
newRefreshInterval := 300
162165
newFirstLabelValue := "collection-cluster"
166+
updatedDomain := "app"
163167
newLiteralRangeName := "week"
164168
searchPanel := SumoSearchPanel{
165169
Key: "search-panel-001",
@@ -211,7 +215,7 @@ func TestAccSumologicDashboard_update(t *testing.T) {
211215
Steps: []resource.TestStep{
212216
{
213217
Config: dashboardCreateConfig(title, description, theme, refreshInterval,
214-
topologyLabel, literalRangeName, textPanel, layout, csvVariable),
218+
topologyLabel, domain, literalRangeName, textPanel, layout, csvVariable),
215219
Check: resource.ComposeTestCheckFunc(
216220
testAccCheckDashboardExists("sumologic_dashboard.tf_crud_test", &dashboard, t),
217221
resource.TestCheckResourceAttr("sumologic_dashboard.tf_crud_test",
@@ -222,6 +226,8 @@ func TestAccSumologicDashboard_update(t *testing.T) {
222226
"theme", theme),
223227
resource.TestCheckResourceAttr("sumologic_dashboard.tf_crud_test",
224228
"topology_label_map.0.data.#", "2"),
229+
resource.TestCheckResourceAttr("sumologic_dashboard.tf_crud_test",
230+
"domain", domain),
225231
resource.TestCheckResourceAttr("sumologic_dashboard.tf_crud_test",
226232
"time_range.0.begin_bounded_time_range.0.from.0.literal_time_range.0.range_name",
227233
literalRangeName),
@@ -241,8 +247,8 @@ func TestAccSumologicDashboard_update(t *testing.T) {
241247
},
242248
{
243249
Config: dashboardUpdateConfig(title, description, newTheme, newRefreshInterval,
244-
firstLabelKey, newFirstLabelValue, newLiteralRangeName, textPanel, searchPanel,
245-
newLayout, newVariables),
250+
firstLabelKey, newFirstLabelValue, updatedDomain, newLiteralRangeName, textPanel,
251+
searchPanel, newLayout, newVariables),
246252
Check: resource.ComposeTestCheckFunc(
247253
testAccCheckDashboardExists("sumologic_dashboard.tf_crud_test", &dashboard, t),
248254
resource.TestCheckResourceAttr("sumologic_dashboard.tf_crud_test",
@@ -253,6 +259,8 @@ func TestAccSumologicDashboard_update(t *testing.T) {
253259
"theme", newTheme),
254260
resource.TestCheckResourceAttr("sumologic_dashboard.tf_crud_test",
255261
"topology_label_map.0.data.#", "1"),
262+
resource.TestCheckResourceAttr("sumologic_dashboard.tf_crud_test",
263+
"domain", updatedDomain),
256264
resource.TestCheckResourceAttr("sumologic_dashboard.tf_crud_test",
257265
"time_range.0.begin_bounded_time_range.0.from.0.literal_time_range.0.range_name",
258266
newLiteralRangeName),
@@ -395,8 +403,8 @@ func dashboardImportConfig(title string) string {
395403
}
396404

397405
func dashboardCreateConfig(title string, description string, theme string, refreshInterval int,
398-
topologyLabel TopologyLabel, rangeName string, textPanel TextPanel, layout GridLayout,
399-
variable Variable) string {
406+
topologyLabel TopologyLabel, domain string, rangeName string, textPanel TextPanel,
407+
layout GridLayout, variable Variable) string {
400408

401409
return fmt.Sprintf(`
402410
data "sumologic_personal_folder" "personalFolder" {}
@@ -416,6 +424,7 @@ func dashboardCreateConfig(title string, description string, theme string, refre
416424
values = ["%s", "%s"]
417425
}
418426
}
427+
domain = "%s"
419428
time_range {
420429
begin_bounded_time_range {
421430
from {
@@ -458,15 +467,16 @@ func dashboardCreateConfig(title string, description string, theme string, refre
458467
}`,
459468
title, description, refreshInterval, theme, firstLabelKey, topologyLabel.Data[firstLabelKey][0],
460469
secondLabelKey, topologyLabel.Data[secondLabelKey][0], topologyLabel.Data[secondLabelKey][1],
461-
rangeName, textPanel.Key, textPanel.Title, textPanel.Text,
470+
domain, rangeName, textPanel.Key, textPanel.Title, textPanel.Text,
462471
layout.LayoutStructures[0].Key, variable.Name, variable.DisplayName, variable.DefaultValue,
463472
variable.SourceDefinition.(CsvVariableSourceDefinition).Values,
464473
)
465474
}
466475

467476
func dashboardUpdateConfig(title string, description string, theme string, refreshInterval int,
468-
topologyLabel string, topologyLabelValue string, rangeName string, textPanel TextPanel,
469-
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 {
470480

471481
loqQuerySourceDef := variables[1].SourceDefinition.(LogQueryVariableSourceDefinition)
472482
csvSourceDef := variables[0].SourceDefinition.(CsvVariableSourceDefinition)
@@ -485,6 +495,7 @@ func dashboardUpdateConfig(title string, description string, theme string, refre
485495
values = ["%s"]
486496
}
487497
}
498+
domain = "%s"
488499
time_range {
489500
begin_bounded_time_range {
490501
from {
@@ -567,8 +578,8 @@ func dashboardUpdateConfig(title string, description string, theme string, refre
567578
hide_from_ui = false
568579
}
569580
}`,
570-
title, description, refreshInterval, theme, topologyLabel, topologyLabelValue, rangeName,
571-
textPanel.Key, textPanel.Title, textPanel.Text,
581+
title, description, refreshInterval, theme, topologyLabel, topologyLabelValue, domain,
582+
rangeName, textPanel.Key, textPanel.Title, textPanel.Text,
572583
searchPanel.Key, searchPanel.Title, searchPanel.Description, searchPanel.Queries[0].QueryString,
573584
searchPanel.Queries[0].QueryKey,
574585
layout.LayoutStructures[0].Key, layout.LayoutStructures[1].Key,

sumologic/sumologic_dashboard.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ type Dashboard struct {
5858
Description string `json:"description"`
5959
FolderId string `json:"folderId"`
6060
TopologyLabelMap *TopologyLabel `json:"topologyLabelMap"`
61+
Domain string `json:"domain"`
6162
RefreshInterval int `json:"refreshInterval"`
6263
TimeRange interface{} `json:"timeRange"`
6364
Panels []interface{} `json:"panels"`

website/docs/r/dashboard.html.markdown

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ resource "sumologic_dashboard" "api-dashboard" {
4040
}
4141
}
4242
43+
domain = "app"
44+
4345
## text panel
4446
panel {
4547
text_panel {
@@ -277,6 +279,7 @@ personal folder.
277279
- `topology_label_map` - (Block List, Max: 1, Optional) Topology labels for the dashboard. See
278280
[topology label map schema](#schema-for-topology_label_map)
279281
for details.
282+
- `domain` - (Optional) Domain of the dashboard. If set denotes that the dashboard concerns a given domain.
280283
- `time_range` - (Block List, Max: 1, Required) Time range of the dashboard. See [time range schema](#schema-for-time_range)
281284
for details.
282285
- `panel` - (Block List, Optional) A list of panels in the dashboard. See [panel schema](#schema-for-panel) for details.

0 commit comments

Comments
 (0)