Skip to content

Commit

Permalink
Fix saved searches alert_track datatype (#64)
Browse files Browse the repository at this point in the history
Co-authored-by: ajayaraman <[email protected]>
  • Loading branch information
anushjay and ajayaraman authored Mar 19, 2021
1 parent d543157 commit 6121460
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion client/models/saved_searches.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ type SavedSearchObject struct {
AlertSuppress bool `json:"alert.suppress" url:"alert.suppress"`
AlertSuppressFields string `json:"alert.suppress.fields,omitempty" url:"alert.suppress.fields,omitempty"`
AlertSuppressPeriod string `json:"alert.suppress.period,omitempty" url:"alert.suppress.period,omitempty"`
AlertTrack string `json:"alert.track,omitempty" url:"alert.track,omitempty"`
AlertTrack bool `json:"alert.track" url:"alert.track"`
AlertComparator string `json:"alert_comparator,omitempty" url:"alert_comparator,omitempty"`
AlertCondition string `json:"alert_condition,omitempty" url:"alert_condition,omitempty"`
AlertThreshold string `json:"alert_threshold,omitempty" url:"alert_threshold,omitempty"`
Expand Down
4 changes: 2 additions & 2 deletions splunk/resource_splunk_saved_searches.go
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ func savedSearches() *schema.Resource {
"Use [number][time-unit] to specify a time. For example: 60 = 60 seconds, 1m = 1 minute, 1h = 60 minutes = 1 hour. ",
},
"alert_track": {
Type: schema.TypeString,
Type: schema.TypeBool,
Optional: true,
Computed: true,
Description: "Valid values: (true | false | auto) Specifies whether to track the actions triggered by this scheduled search." +
Expand Down Expand Up @@ -1545,7 +1545,7 @@ func getSavedSearchesConfig(d *schema.ResourceData) (savedSearchesObj *models.Sa
AlertSuppressFields: d.Get("alert_suppress_fields").(string),
AlertSuppressPeriod: d.Get("alert_suppress_period").(string),
AlertThreshold: d.Get("alert_threshold").(string),
AlertTrack: d.Get("alert_track").(string),
AlertTrack: d.Get("alert_track").(bool),
AlertType: d.Get("alert_type").(string),
AutoSummarize: d.Get("auto_summarize").(bool),
AutoSummarizeCommand: d.Get("auto_summarize_command").(string),
Expand Down
4 changes: 4 additions & 0 deletions splunk/resource_splunk_saved_searches_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ resource "splunk_saved_searches" "test" {
action_email_subject = "Splunk Alert: $name$"
action_email_to = "[email protected]"
action_email_track_alert = true
alert_track = true
dispatch_earliest_time = "rt-15m"
dispatch_latest_time = "rt-0m"
dispatch_index_earliest = "-10m"
Expand Down Expand Up @@ -52,6 +53,7 @@ resource "splunk_saved_searches" "test" {
action_email_subject = "Splunk Alert: $name$"
action_email_to = "[email protected]"
action_email_track_alert = true
alert_track = true
dispatch_earliest_time = "rt-15m"
dispatch_latest_time = "rt-0m"
dispatch_index_earliest = "-20m"
Expand Down Expand Up @@ -184,6 +186,7 @@ func TestAccSplunkSavedSearches(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "action_email_subject", "Splunk Alert: $name$"),
resource.TestCheckResourceAttr(resourceName, "action_email_to", "[email protected]"),
resource.TestCheckResourceAttr(resourceName, "action_email_track_alert", "true"),
resource.TestCheckResourceAttr(resourceName, "alert_track", "true"),
resource.TestCheckResourceAttr(resourceName, "dispatch_earliest_time", "rt-15m"),
resource.TestCheckResourceAttr(resourceName, "dispatch_latest_time", "rt-0m"),
resource.TestCheckResourceAttr(resourceName, "dispatch_index_earliest", "-10m"),
Expand All @@ -209,6 +212,7 @@ func TestAccSplunkSavedSearches(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "action_email_subject", "Splunk Alert: $name$"),
resource.TestCheckResourceAttr(resourceName, "action_email_to", "[email protected]"),
resource.TestCheckResourceAttr(resourceName, "action_email_track_alert", "true"),
resource.TestCheckResourceAttr(resourceName, "alert_track", "true"),
resource.TestCheckResourceAttr(resourceName, "dispatch_earliest_time", "rt-15m"),
resource.TestCheckResourceAttr(resourceName, "dispatch_latest_time", "rt-0m"),
resource.TestCheckResourceAttr(resourceName, "dispatch_index_earliest", "-20m"),
Expand Down

0 comments on commit 6121460

Please sign in to comment.