Skip to content

Commit 7ead4a2

Browse files
committed
Fixed timerange read
1 parent d509020 commit 7ead4a2

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

sumologic/resource_sumologic_monitors_library_monitor.go

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

33
import (
4-
"fmt"
54
"log"
5+
"strings"
66

77
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
88
)
@@ -352,11 +352,10 @@ func resourceSumologicMonitorsLibraryMonitorRead(d *schema.ResourceData, meta in
352352
triggers := make([]interface{}, len(monitor.Triggers))
353353
for i, t := range monitor.Triggers {
354354
triggers[i] = map[string]interface{}{
355-
"trigger_type": t.TriggerType,
356-
"threshold": t.Threshold,
357-
"threshold_type": t.ThresholdType,
358-
// we don't read the TimeRange because it overwrites our local timerange and leads to errors
359-
"time_range": d.Get(fmt.Sprintf("triggers.%d.time_range", i)),
355+
"trigger_type": t.TriggerType,
356+
"threshold": t.Threshold,
357+
"threshold_type": t.ThresholdType,
358+
"time_range": strings.TrimPrefix(t.TimeRange, "-"),
360359
"occurrence_type": t.OccurrenceType,
361360
"trigger_source": t.TriggerSource,
362361
"detection_method": t.DetectionMethod,

sumologic/resource_sumologic_monitors_library_monitor_test.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ func TestAccSumologicMonitorsLibraryMonitor_create(t *testing.T) {
111111
resource.TestCheckResourceAttr("sumologic_monitor.test", "content_type", testContentType),
112112
resource.TestCheckResourceAttr("sumologic_monitor.test", "queries.0.row_id", testQueries[0].RowID),
113113
resource.TestCheckResourceAttr("sumologic_monitor.test", "triggers.0.trigger_type", testTriggers[0].TriggerType),
114+
resource.TestCheckResourceAttr("sumologic_monitor.test", "triggers.0.time_range", testTriggers[0].TimeRange),
114115
resource.TestCheckResourceAttr("sumologic_monitor.test", "notifications.0.notification.0.connection_type", testNotifications[0].Notification.(EmailNotification).ConnectionType),
115116
),
116117
},
@@ -195,7 +196,7 @@ func TestAccSumologicMonitorsLibraryMonitor_update(t *testing.T) {
195196
{
196197
ThresholdType: "GreaterThan",
197198
Threshold: 40.0,
198-
TimeRange: "15m",
199+
TimeRange: "30m",
199200
OccurrenceType: "ResultCount",
200201
TriggerSource: "AllResults",
201202
TriggerType: "Critical",
@@ -204,7 +205,7 @@ func TestAccSumologicMonitorsLibraryMonitor_update(t *testing.T) {
204205
{
205206
ThresholdType: "LessThanOrEqual",
206207
Threshold: 40.0,
207-
TimeRange: "15m",
208+
TimeRange: "30m",
208209
OccurrenceType: "ResultCount",
209210
TriggerSource: "AllResults",
210211
TriggerType: "ResolvedCritical",
@@ -253,6 +254,7 @@ func TestAccSumologicMonitorsLibraryMonitor_update(t *testing.T) {
253254
resource.TestCheckResourceAttr("sumologic_monitor.test", "content_type", testContentType),
254255
resource.TestCheckResourceAttr("sumologic_monitor.test", "queries.0.row_id", testQueries[0].RowID),
255256
resource.TestCheckResourceAttr("sumologic_monitor.test", "triggers.0.trigger_type", testTriggers[0].TriggerType),
257+
resource.TestCheckResourceAttr("sumologic_monitor.test", "triggers.0.time_range", testTriggers[0].TimeRange),
256258
resource.TestCheckResourceAttr("sumologic_monitor.test", "notifications.0.notification.0.connection_type", testNotifications[0].Notification.(EmailNotification).ConnectionType),
257259
),
258260
},
@@ -267,6 +269,7 @@ func TestAccSumologicMonitorsLibraryMonitor_update(t *testing.T) {
267269
resource.TestCheckResourceAttr("sumologic_monitor.test", "content_type", testUpdatedContentType),
268270
resource.TestCheckResourceAttr("sumologic_monitor.test", "queries.0.row_id", testUpdatedQueries[0].RowID),
269271
resource.TestCheckResourceAttr("sumologic_monitor.test", "triggers.0.trigger_type", testUpdatedTriggers[0].TriggerType),
272+
resource.TestCheckResourceAttr("sumologic_monitor.test", "triggers.0.time_range", testUpdatedTriggers[0].TimeRange),
270273
resource.TestCheckResourceAttr("sumologic_monitor.test", "notifications.0.notification.0.connection_type", testUpdatedNotifications[0].Notification.(EmailNotification).ConnectionType),
271274
),
272275
},
@@ -398,7 +401,7 @@ resource "sumologic_monitor" "test" {
398401
triggers {
399402
threshold_type = "GreaterThan"
400403
threshold = 40.0
401-
time_range = "15m"
404+
time_range = "30m"
402405
occurrence_type = "ResultCount"
403406
trigger_source = "AllResults"
404407
trigger_type = "Critical"
@@ -407,7 +410,7 @@ resource "sumologic_monitor" "test" {
407410
triggers {
408411
threshold_type = "LessThanOrEqual"
409412
threshold = 40.0
410-
time_range = "15m"
413+
time_range = "30m"
411414
occurrence_type = "ResultCount"
412415
trigger_source = "AllResults"
413416
trigger_type = "ResolvedCritical"

0 commit comments

Comments
 (0)