Skip to content

Commit c9c713e

Browse files
committed
Fix formatting and remove schema duplication
1 parent 24b381b commit c9c713e

File tree

2 files changed

+9
-26
lines changed

2 files changed

+9
-26
lines changed

sumologic/resource_sumologic_monitors_library_monitor.go

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -251,26 +251,10 @@ func getMonitorSchema() map[string]*schema.Schema {
251251
Optional: true,
252252
ValidateFunc: validation.StringInSlice([]string{"Critical", "Warning", "MissingData", "ResolvedCritical", "ResolvedWarning", "ResolvedMissingData"}, false),
253253
},
254-
"threshold": {
255-
Type: schema.TypeFloat,
256-
Optional: true,
257-
},
258-
"threshold_type": {
259-
Type: schema.TypeString,
260-
Optional: true,
261-
ValidateFunc: validation.StringInSlice([]string{"LessThan", "LessThanOrEqual", "GreaterThan", "GreaterThanOrEqual"}, false),
262-
},
263-
"time_range": {
264-
Type: schema.TypeString,
265-
Optional: true,
266-
ValidateFunc: validation.StringMatch(regexp.MustCompile(`^-?(\d)+[smhd]$`), "Time range must be in the format '-?\\d+[smhd]'. Examples: -15m, 1d, etc."),
267-
DiffSuppressFunc: SuppressEquivalentTimeDiff(false),
268-
},
269-
"frequency": {
270-
Type: schema.TypeString,
271-
Optional: true,
272-
ValidateFunc: validation.StringMatch(regexp.MustCompile(`^(\d)+[smhd]`), "Frequency time must be in the format '\\d+[smhd]'. Examples: 0m, 15m, 1d, etc."),
273-
},
254+
"threshold": &thresholdSchema,
255+
"threshold_type": &thresholdTypeSchema,
256+
"time_range": &timeRangeWithFormatSchema,
257+
"frequency": &frequencySchema,
274258
"trigger_source": {
275259
Type: schema.TypeString,
276260
Optional: true,
@@ -822,10 +806,9 @@ var thresholdTypeSchema = schema.Schema{
822806
}
823807

824808
var frequencySchema = schema.Schema{
825-
Type: schema.TypeString,
826-
Optional: true,
827-
ValidateFunc: validation.StringMatch(regexp.MustCompile(`^(\d)+[smhd]`),
828-
"Frequency time must be in the format '\\d+[smhd]'. Examples: 0m, 15m, 1d, etc."),
809+
Type: schema.TypeString,
810+
Optional: true,
811+
ValidateFunc: validation.StringMatch(regexp.MustCompile(`^(\d)+[smhd]`), "Frequency time must be in the format '\\d+[smhd]'. Examples: 1m, 2m, 10m, 20m, 1h"),
829812
}
830813

831814
func resourceSumologicMonitorsLibraryMonitorCreate(d *schema.ResourceData, meta interface{}) error {

sumologic/resource_sumologic_monitors_library_monitor_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,7 +1306,7 @@ var exampleLogsStaticTriggerConditionBlock = `
13061306
logs_static_condition {
13071307
critical {
13081308
time_range = "60m"
1309-
frequency = "5m"
1309+
frequency = "5m"
13101310
alert {
13111311
threshold = 100.0
13121312
threshold_type = "GreaterThan"
@@ -1323,7 +1323,7 @@ var exampleLogsStaticTriggerConditionBlockWithResolutionWindow = `
13231323
logs_static_condition {
13241324
critical {
13251325
time_range = "1h"
1326-
frequency = "5m"
1326+
frequency = "5m"
13271327
alert {
13281328
threshold = 100.0
13291329
threshold_type = "GreaterThan"

0 commit comments

Comments
 (0)