Skip to content

Commit 589261c

Browse files
authored
Merge branch 'master' into SUMO-199581-timezone-in-monitor-def
2 parents ae5067e + e41f6cb commit 589261c

6 files changed

+38
-19
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
## 2.27.1 (Unreleased)
1+
## 2.28.0 (Unreleased)
22
FEATURES:
33
* resource/sumologic_monitor: Added support for setting `time_zone` at Monitor level for notifications content (GH-586)
44

5+
## 2.27.1 (November 14, 2023)
6+
BUG FIXES:
7+
* Fixes `resource_sumologic_cse_match_list` constant change when defining a match list containing a custom column using the custom columns name instead of ID (GH-591)
8+
59
## 2.27.0 (September 28, 2023)
610
FEATURES:
711
* **New Resource:** sumologic_cse_tag_schema (GH-575)

sumologic/resource_sumologic_cse_match_list.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package sumologic
33
import (
44
"fmt"
55
"log"
6+
"regexp"
67
"time"
78

89
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
@@ -93,7 +94,11 @@ func resourceSumologicCSEMatchListRead(d *schema.ResourceData, meta interface{})
9394
var CSEMatchList *CSEMatchListGet
9495
id := d.Id()
9596

96-
CSEMatchList, err := c.GetCSEMatchList(id)
97+
// Determine whether the target column is defined using its ID or its name
98+
definedTargetColumnIsId, _ := regexp.MatchString("^-?[0-9]*$", d.Get("target_column").(string))
99+
definedTargetColumnIsName := !definedTargetColumnIsId
100+
101+
CSEMatchList, err := c.GetCSEMatchList(id, definedTargetColumnIsName)
97102
if err != nil {
98103
log.Printf("[WARN] CSE Match List not found when looking by id: %s, err: %v", id, err)
99104

sumologic/resource_sumologic_cse_match_list_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func testAccCSEMatchListDestroy(s *terraform.State) error {
7878
return fmt.Errorf("CSE Match List destruction check: CSE Match List ID is not set")
7979
}
8080

81-
s, err := client.GetCSEMatchList(rs.Primary.ID)
81+
s, err := client.GetCSEMatchList(rs.Primary.ID, false)
8282
if err != nil {
8383
return fmt.Errorf("Encountered an error: " + err.Error())
8484
}
@@ -136,7 +136,8 @@ func testCheckCSEMatchListExists(n string, matchList *CSEMatchListGet) resource.
136136
return fmt.Errorf("match List ID is not set")
137137
}
138138
c := testAccProvider.Meta().(*Client)
139-
matchListResp, err := c.GetCSEMatchList(rs.Primary.ID)
139+
140+
matchListResp, err := c.GetCSEMatchList(rs.Primary.ID, false)
140141
if err != nil {
141142
return err
142143
}

sumologic/resource_sumologic_cse_outlier_rule_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ package sumologic
33
import (
44
"bytes"
55
"fmt"
6-
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
7-
"github.com/hashicorp/terraform-plugin-sdk/terraform"
8-
"github.com/stretchr/testify/assert"
96
"strings"
107
"testing"
118
"text/template"
9+
10+
"github.com/google/uuid"
11+
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
12+
"github.com/hashicorp/terraform-plugin-sdk/terraform"
13+
"github.com/stretchr/testify/assert"
1214
)
1315

1416
func TestAccSumologicCSEOutlierRule_createAndUpdate(t *testing.T) {
@@ -27,7 +29,7 @@ func TestAccSumologicCSEOutlierRule_createAndUpdate(t *testing.T) {
2729
GroupByFields: []string{"user_username"},
2830
IsPrototype: false,
2931
MatchExpression: `objectType="Network"`,
30-
Name: "OutlierRuleTerraformTest",
32+
Name: fmt.Sprintf("OutlierRuleTerraformTest %s", uuid.New()),
3133
NameExpression: "OutlierRuleTerraformTest - {{ user_username }}",
3234
RetentionWindowSize: "1209600000",
3335
Severity: 1,

sumologic/resource_sumologic_user_test.go

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"strings"
1818
"testing"
1919

20+
"github.com/google/uuid"
2021
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
2122
"github.com/hashicorp/terraform-plugin-sdk/terraform"
2223
)
@@ -164,11 +165,13 @@ func TestAccSumologicUser_update(t *testing.T) {
164165
}
165166

166167
func testAccCheckSumologicUserConfigImported(firstName string, lastName string, email string, isActive bool, transferTo string) string {
168+
testUuid := uuid.New()
169+
167170
return fmt.Sprintf(`
168171
resource "sumologic_role" "testRole" {
169-
name = "testRole Name"
172+
name = "testRole Name %s"
170173
capabilities = []
171-
description = "testRole Description"
174+
description = "testRole Description %s"
172175
filter_predicate = ""
173176
}
174177
resource "sumologic_user" "foo" {
@@ -179,15 +182,17 @@ resource "sumologic_user" "foo" {
179182
is_active = %t
180183
transfer_to = "%s"
181184
}
182-
`, firstName, lastName, email, isActive, transferTo)
185+
`, testUuid, testUuid, firstName, lastName, email, isActive, transferTo)
183186
}
184187

185188
func testAccSumologicUser(firstName string, lastName string, email string, isActive bool, transferTo string) string {
189+
testUuid := uuid.New()
190+
186191
return fmt.Sprintf(`
187192
resource "sumologic_role" "testRole" {
188-
name = "testRole Name"
193+
name = "testRole Name %s"
189194
capabilities = []
190-
description = "testRole Description"
195+
description = "testRole Description %s"
191196
filter_predicate = ""
192197
}
193198
resource "sumologic_user" "test" {
@@ -198,15 +203,17 @@ resource "sumologic_user" "test" {
198203
is_active = %t
199204
transfer_to = "%s"
200205
}
201-
`, firstName, lastName, email, isActive, transferTo)
206+
`, testUuid, testUuid, firstName, lastName, email, isActive, transferTo)
202207
}
203208

204209
func testAccSumologicUserUpdate(firstName string, lastName string, email string, isActive bool, transferTo string) string {
210+
testUuid := uuid.New()
211+
205212
return fmt.Sprintf(`
206213
resource "sumologic_role" "testRole" {
207-
name = "testRole Name"
214+
name = "testRole Name %s"
208215
capabilities = []
209-
description = "testRole Description"
216+
description = "testRole Description %s"
210217
filter_predicate = ""
211218
}
212219
resource "sumologic_user" "test" {
@@ -217,7 +224,7 @@ resource "sumologic_user" "test" {
217224
is_active = %t
218225
transfer_to = "%s"
219226
}
220-
`, firstName, lastName, email, isActive, transferTo)
227+
`, testUuid, testUuid, firstName, lastName, email, isActive, transferTo)
221228
}
222229

223230
func testAccCheckUserAttributes(name string) resource.TestCheckFunc {

sumologic/sumologic_cse_match_list.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"fmt"
66
)
77

8-
func (s *Client) GetCSEMatchList(id string) (*CSEMatchListGet, error) {
9-
data, _, err := s.Get(fmt.Sprintf("sec/v1/match-lists/%s", id))
8+
func (s *Client) GetCSEMatchList(id string, getCustomTargetColumnName bool) (*CSEMatchListGet, error) {
9+
data, _, err := s.Get(fmt.Sprintf("sec/v1/match-lists/%s?getTargetCustomColumnName=%t", id, getCustomTargetColumnName))
1010
if err != nil {
1111
return nil, err
1212
}

0 commit comments

Comments
 (0)