Skip to content

Commit 4fb65ad

Browse files
committed
Fix topologyLabel to allow more than one label
1 parent cc379df commit 4fb65ad

File tree

3 files changed

+138
-150
lines changed

3 files changed

+138
-150
lines changed

sumologic/resource_sumologic_dashboard.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,7 @@ 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"].([]interface{}); len(items) >= 1 {
952952
labelMap := make(map[string][]string)
953953
for _, item := range items {
954954
dataItem := item.(map[string]interface{})

sumologic/resource_sumologic_kinesis_log_source_test.go

Lines changed: 137 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -1,157 +1,157 @@
11
package sumologic
22

33
import (
4-
"fmt"
5-
"os"
6-
"strconv"
7-
"testing"
4+
"fmt"
5+
"os"
6+
"strconv"
7+
"testing"
88

9-
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
10-
"github.com/hashicorp/terraform-plugin-sdk/terraform"
9+
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
10+
"github.com/hashicorp/terraform-plugin-sdk/terraform"
1111
)
1212

1313
func TestAccSumologicKinesisLogSource_create(t *testing.T) {
14-
var kinesisLogSource KinesisLogSource
15-
var collector Collector
16-
cName, cDescription, cCategory := getRandomizedParams()
17-
sName, sDescription, sCategory := getRandomizedParams()
18-
kinesisLogResourceName := "sumologic_kinesis_log_source.kinesisLog"
19-
testAwsRoleArn := os.Getenv("SUMOLOGIC_TEST_ROLE_ARN")
20-
testAwsBucket := os.Getenv("SUMOLOGIC_TEST_BUCKET_NAME")
21-
resource.Test(t, resource.TestCase{
22-
PreCheck: func() { testAccPreCheckWithAWS(t) },
23-
Providers: testAccProviders,
24-
CheckDestroy: testAccCheckKinesisLogSourceDestroy,
25-
Steps: []resource.TestStep{
26-
{
27-
Config: testAccSumologicKinesisLogSourceConfig(cName, cDescription, cCategory, sName, sDescription, sCategory, testAwsRoleArn, testAwsBucket),
28-
Check: resource.ComposeTestCheckFunc(
29-
testAccCheckKinesisLogSourceExists(kinesisLogResourceName, &kinesisLogSource),
30-
testAccCheckKinesisLogSourceValues(&kinesisLogSource, sName, sDescription, sCategory),
31-
testAccCheckCollectorExists("sumologic_collector.test", &collector),
32-
testAccCheckCollectorValues(&collector, cName, cDescription, cCategory, "Etc/UTC", ""),
33-
resource.TestCheckResourceAttrSet(kinesisLogResourceName, "id"),
34-
resource.TestCheckResourceAttr(kinesisLogResourceName, "name", sName),
35-
resource.TestCheckResourceAttr(kinesisLogResourceName, "description", sDescription),
36-
resource.TestCheckResourceAttr(kinesisLogResourceName, "category", sCategory),
37-
resource.TestCheckResourceAttr(kinesisLogResourceName, "content_type", "KinesisLog"),
38-
resource.TestCheckResourceAttr(kinesisLogResourceName, "path.0.type", "KinesisLogPath"),
39-
),
40-
},
41-
},
42-
})
14+
var kinesisLogSource KinesisLogSource
15+
var collector Collector
16+
cName, cDescription, cCategory := getRandomizedParams()
17+
sName, sDescription, sCategory := getRandomizedParams()
18+
kinesisLogResourceName := "sumologic_kinesis_log_source.kinesisLog"
19+
testAwsRoleArn := os.Getenv("SUMOLOGIC_TEST_ROLE_ARN")
20+
testAwsBucket := os.Getenv("SUMOLOGIC_TEST_BUCKET_NAME")
21+
resource.Test(t, resource.TestCase{
22+
PreCheck: func() { testAccPreCheckWithAWS(t) },
23+
Providers: testAccProviders,
24+
CheckDestroy: testAccCheckKinesisLogSourceDestroy,
25+
Steps: []resource.TestStep{
26+
{
27+
Config: testAccSumologicKinesisLogSourceConfig(cName, cDescription, cCategory, sName, sDescription, sCategory, testAwsRoleArn, testAwsBucket),
28+
Check: resource.ComposeTestCheckFunc(
29+
testAccCheckKinesisLogSourceExists(kinesisLogResourceName, &kinesisLogSource),
30+
testAccCheckKinesisLogSourceValues(&kinesisLogSource, sName, sDescription, sCategory),
31+
testAccCheckCollectorExists("sumologic_collector.test", &collector),
32+
testAccCheckCollectorValues(&collector, cName, cDescription, cCategory, "Etc/UTC", ""),
33+
resource.TestCheckResourceAttrSet(kinesisLogResourceName, "id"),
34+
resource.TestCheckResourceAttr(kinesisLogResourceName, "name", sName),
35+
resource.TestCheckResourceAttr(kinesisLogResourceName, "description", sDescription),
36+
resource.TestCheckResourceAttr(kinesisLogResourceName, "category", sCategory),
37+
resource.TestCheckResourceAttr(kinesisLogResourceName, "content_type", "KinesisLog"),
38+
resource.TestCheckResourceAttr(kinesisLogResourceName, "path.0.type", "KinesisLogPath"),
39+
),
40+
},
41+
},
42+
})
4343
}
4444
func TestAccSumologicKinesisLogSource_update(t *testing.T) {
45-
var kinesisLogSource KinesisLogSource
46-
cName, cDescription, cCategory := getRandomizedParams()
47-
sName, sDescription, sCategory := getRandomizedParams()
48-
sNameUpdated, sDescriptionUpdated, sCategoryUpdated := getRandomizedParams()
49-
kinesisLogResourceName := "sumologic_kinesis_log_source.kinesisLog"
50-
testAwsRoleArn := os.Getenv("SUMOLOGIC_TEST_ROLE_ARN")
51-
testAwsBucket := os.Getenv("SUMOLOGIC_TEST_BUCKET_NAME")
52-
resource.Test(t, resource.TestCase{
53-
PreCheck: func() { testAccPreCheckWithAWS(t) },
54-
Providers: testAccProviders,
55-
CheckDestroy: testAccCheckHTTPSourceDestroy,
56-
Steps: []resource.TestStep{
57-
{
58-
Config: testAccSumologicKinesisLogSourceConfig(cName, cDescription, cCategory, sName, sDescription, sCategory, testAwsRoleArn, testAwsBucket),
59-
Check: resource.ComposeTestCheckFunc(
60-
testAccCheckKinesisLogSourceExists(kinesisLogResourceName, &kinesisLogSource),
61-
testAccCheckKinesisLogSourceValues(&kinesisLogSource, sName, sDescription, sCategory),
62-
resource.TestCheckResourceAttrSet(kinesisLogResourceName, "id"),
63-
resource.TestCheckResourceAttr(kinesisLogResourceName, "name", sName),
64-
resource.TestCheckResourceAttr(kinesisLogResourceName, "description", sDescription),
65-
resource.TestCheckResourceAttr(kinesisLogResourceName, "category", sCategory),
66-
resource.TestCheckResourceAttr(kinesisLogResourceName, "content_type", "KinesisLog"),
67-
resource.TestCheckResourceAttr(kinesisLogResourceName, "path.0.type", "KinesisLogPath"),
68-
),
69-
},
70-
{
71-
Config: testAccSumologicKinesisLogSourceConfig(cName, cDescription, cCategory, sNameUpdated, sDescriptionUpdated, sCategoryUpdated, testAwsRoleArn, testAwsBucket),
72-
Check: resource.ComposeTestCheckFunc(
73-
testAccCheckKinesisLogSourceExists(kinesisLogResourceName, &kinesisLogSource),
74-
testAccCheckKinesisLogSourceValues(&kinesisLogSource, sNameUpdated, sDescriptionUpdated, sCategoryUpdated),
75-
resource.TestCheckResourceAttrSet(kinesisLogResourceName, "id"),
76-
resource.TestCheckResourceAttr(kinesisLogResourceName, "name", sNameUpdated),
77-
resource.TestCheckResourceAttr(kinesisLogResourceName, "description", sDescriptionUpdated),
78-
resource.TestCheckResourceAttr(kinesisLogResourceName, "category", sCategoryUpdated),
79-
resource.TestCheckResourceAttr(kinesisLogResourceName, "content_type", "KinesisLog"),
80-
resource.TestCheckResourceAttr(kinesisLogResourceName, "path.0.type", "KinesisLogPath"),
81-
),
82-
},
83-
},
84-
})
45+
var kinesisLogSource KinesisLogSource
46+
cName, cDescription, cCategory := getRandomizedParams()
47+
sName, sDescription, sCategory := getRandomizedParams()
48+
sNameUpdated, sDescriptionUpdated, sCategoryUpdated := getRandomizedParams()
49+
kinesisLogResourceName := "sumologic_kinesis_log_source.kinesisLog"
50+
testAwsRoleArn := os.Getenv("SUMOLOGIC_TEST_ROLE_ARN")
51+
testAwsBucket := os.Getenv("SUMOLOGIC_TEST_BUCKET_NAME")
52+
resource.Test(t, resource.TestCase{
53+
PreCheck: func() { testAccPreCheckWithAWS(t) },
54+
Providers: testAccProviders,
55+
CheckDestroy: testAccCheckHTTPSourceDestroy,
56+
Steps: []resource.TestStep{
57+
{
58+
Config: testAccSumologicKinesisLogSourceConfig(cName, cDescription, cCategory, sName, sDescription, sCategory, testAwsRoleArn, testAwsBucket),
59+
Check: resource.ComposeTestCheckFunc(
60+
testAccCheckKinesisLogSourceExists(kinesisLogResourceName, &kinesisLogSource),
61+
testAccCheckKinesisLogSourceValues(&kinesisLogSource, sName, sDescription, sCategory),
62+
resource.TestCheckResourceAttrSet(kinesisLogResourceName, "id"),
63+
resource.TestCheckResourceAttr(kinesisLogResourceName, "name", sName),
64+
resource.TestCheckResourceAttr(kinesisLogResourceName, "description", sDescription),
65+
resource.TestCheckResourceAttr(kinesisLogResourceName, "category", sCategory),
66+
resource.TestCheckResourceAttr(kinesisLogResourceName, "content_type", "KinesisLog"),
67+
resource.TestCheckResourceAttr(kinesisLogResourceName, "path.0.type", "KinesisLogPath"),
68+
),
69+
},
70+
{
71+
Config: testAccSumologicKinesisLogSourceConfig(cName, cDescription, cCategory, sNameUpdated, sDescriptionUpdated, sCategoryUpdated, testAwsRoleArn, testAwsBucket),
72+
Check: resource.ComposeTestCheckFunc(
73+
testAccCheckKinesisLogSourceExists(kinesisLogResourceName, &kinesisLogSource),
74+
testAccCheckKinesisLogSourceValues(&kinesisLogSource, sNameUpdated, sDescriptionUpdated, sCategoryUpdated),
75+
resource.TestCheckResourceAttrSet(kinesisLogResourceName, "id"),
76+
resource.TestCheckResourceAttr(kinesisLogResourceName, "name", sNameUpdated),
77+
resource.TestCheckResourceAttr(kinesisLogResourceName, "description", sDescriptionUpdated),
78+
resource.TestCheckResourceAttr(kinesisLogResourceName, "category", sCategoryUpdated),
79+
resource.TestCheckResourceAttr(kinesisLogResourceName, "content_type", "KinesisLog"),
80+
resource.TestCheckResourceAttr(kinesisLogResourceName, "path.0.type", "KinesisLogPath"),
81+
),
82+
},
83+
},
84+
})
8585
}
8686
func testAccCheckKinesisLogSourceDestroy(s *terraform.State) error {
87-
client := testAccProvider.Meta().(*Client)
88-
for _, rs := range s.RootModule().Resources {
89-
if rs.Type != "sumologic_kinesis_log_source" {
90-
continue
91-
}
92-
if rs.Primary.ID == "" {
93-
return fmt.Errorf("HTTP Source destruction check: HTTP Source ID is not set")
94-
}
95-
id, err := strconv.Atoi(rs.Primary.ID)
96-
if err != nil {
97-
return fmt.Errorf("Encountered an error: " + err.Error())
98-
}
99-
collectorID, err := strconv.Atoi(rs.Primary.Attributes["collector_id"])
100-
if err != nil {
101-
return fmt.Errorf("Encountered an error: " + err.Error())
102-
}
103-
s, err := client.GetKinesisLogSource(collectorID, id)
104-
if err != nil {
105-
return fmt.Errorf("Encountered an error: " + err.Error())
106-
}
107-
if s != nil {
108-
return fmt.Errorf("KinesisLog Source still exists")
109-
}
110-
}
111-
return nil
87+
client := testAccProvider.Meta().(*Client)
88+
for _, rs := range s.RootModule().Resources {
89+
if rs.Type != "sumologic_kinesis_log_source" {
90+
continue
91+
}
92+
if rs.Primary.ID == "" {
93+
return fmt.Errorf("HTTP Source destruction check: HTTP Source ID is not set")
94+
}
95+
id, err := strconv.Atoi(rs.Primary.ID)
96+
if err != nil {
97+
return fmt.Errorf("Encountered an error: " + err.Error())
98+
}
99+
collectorID, err := strconv.Atoi(rs.Primary.Attributes["collector_id"])
100+
if err != nil {
101+
return fmt.Errorf("Encountered an error: " + err.Error())
102+
}
103+
s, err := client.GetKinesisLogSource(collectorID, id)
104+
if err != nil {
105+
return fmt.Errorf("Encountered an error: " + err.Error())
106+
}
107+
if s != nil {
108+
return fmt.Errorf("KinesisLog Source still exists")
109+
}
110+
}
111+
return nil
112112
}
113113
func testAccCheckKinesisLogSourceExists(n string, kinesisLogSource *KinesisLogSource) resource.TestCheckFunc {
114-
return func(s *terraform.State) error {
115-
rs, ok := s.RootModule().Resources[n]
116-
if !ok {
117-
return fmt.Errorf("not found: %s", n)
118-
}
119-
if rs.Primary.ID == "" {
120-
return fmt.Errorf("KinesisLog Source ID is not set")
121-
}
122-
id, err := strconv.Atoi(rs.Primary.ID)
123-
if err != nil {
124-
return fmt.Errorf("KinesisLog Source id should be int; got %s", rs.Primary.ID)
125-
}
126-
collectorID, err := strconv.Atoi(rs.Primary.Attributes["collector_id"])
127-
if err != nil {
128-
return fmt.Errorf("Encountered an error: " + err.Error())
129-
}
130-
c := testAccProvider.Meta().(*Client)
131-
kinesisLogSourceResp, err := c.GetKinesisLogSource(collectorID, id)
132-
if err != nil {
133-
return err
134-
}
135-
*kinesisLogSource = *kinesisLogSourceResp
136-
return nil
137-
}
114+
return func(s *terraform.State) error {
115+
rs, ok := s.RootModule().Resources[n]
116+
if !ok {
117+
return fmt.Errorf("not found: %s", n)
118+
}
119+
if rs.Primary.ID == "" {
120+
return fmt.Errorf("KinesisLog Source ID is not set")
121+
}
122+
id, err := strconv.Atoi(rs.Primary.ID)
123+
if err != nil {
124+
return fmt.Errorf("KinesisLog Source id should be int; got %s", rs.Primary.ID)
125+
}
126+
collectorID, err := strconv.Atoi(rs.Primary.Attributes["collector_id"])
127+
if err != nil {
128+
return fmt.Errorf("Encountered an error: " + err.Error())
129+
}
130+
c := testAccProvider.Meta().(*Client)
131+
kinesisLogSourceResp, err := c.GetKinesisLogSource(collectorID, id)
132+
if err != nil {
133+
return err
134+
}
135+
*kinesisLogSource = *kinesisLogSourceResp
136+
return nil
137+
}
138138
}
139139
func testAccCheckKinesisLogSourceValues(kinesisLogSource *KinesisLogSource, name, description, category string) resource.TestCheckFunc {
140-
return func(s *terraform.State) error {
141-
if kinesisLogSource.Name != name {
142-
return fmt.Errorf("bad name, expected \"%s\", got: %#v", name, kinesisLogSource.Name)
143-
}
144-
if kinesisLogSource.Description != description {
145-
return fmt.Errorf("bad description, expected \"%s\", got: %#v", description, kinesisLogSource.Description)
146-
}
147-
if kinesisLogSource.Category != category {
148-
return fmt.Errorf("bad category, expected \"%s\", got: %#v", category, kinesisLogSource.Category)
149-
}
150-
return nil
151-
}
140+
return func(s *terraform.State) error {
141+
if kinesisLogSource.Name != name {
142+
return fmt.Errorf("bad name, expected \"%s\", got: %#v", name, kinesisLogSource.Name)
143+
}
144+
if kinesisLogSource.Description != description {
145+
return fmt.Errorf("bad description, expected \"%s\", got: %#v", description, kinesisLogSource.Description)
146+
}
147+
if kinesisLogSource.Category != category {
148+
return fmt.Errorf("bad category, expected \"%s\", got: %#v", category, kinesisLogSource.Category)
149+
}
150+
return nil
151+
}
152152
}
153153
func testAccSumologicKinesisLogSourceConfig(cName, cDescription, cCategory, sName, sDescription, sCategory, testAwsRoleArn, testAwsBucket string) string {
154-
return fmt.Sprintf(`
154+
return fmt.Sprintf(`
155155
resource "sumologic_collector" "test" {
156156
name = "%s"
157157
description = "%s"

website/docs/r/dashboard.html.markdown

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,6 @@ with the settings of the parent panel.
356356
- `description` - (Optional) Description of the panel.
357357
- `time_range` - (Block List, Max: 1, Optional) Time range of the panel. See [time_range schema](#schema-for-time_range)
358358
for details.
359-
- `coloring_rule` - (Block List, Optional) Coloring rules for the panel. See [coloring_rule schema](#schema-for-coloring_rule)
360-
for details.
361359
- `linked_dashboard` - (Block List, Optional) A list of linked dashboards. See
362360
[linked_dashboard schema](#schema-for-linked_dashboard) for details.
363361

@@ -386,16 +384,6 @@ One of `Basic` or `Advanced`.
386384
- `key` - (Required) The key of the operator parameter.
387385
- `value` - (Required) The value of the operator parameter.
388386

389-
### Schema for `coloring_rule`
390-
- `scope` - (Required) Regex string to match queries to apply coloring to.
391-
- `single_series_aggregate_function` - (Required) Function to aggregate one series into one single value.
392-
- `multiple_series_aggregate_function` - (Required) Function to aggregate the aggregate values of multiple time series
393-
into one single value.
394-
- `color_threshold` - (Block List, Optional) A list of color threshold object.
395-
- `color` - (Required) Color for the threshold.
396-
- `min` - (Optional) Absolute inclusive threshold to color by.
397-
- `max` - (Optional) Absolute exclusive threshold to color by.
398-
399387
### Schema for `linked_dashboard`
400388
- `id` - (Required) Identifier of the linked dashboard.
401389
- `relative_path` - (Optional) Relative path of the linked dashboard to the dashboard of the linking panel.

0 commit comments

Comments
 (0)