From 61214607ab911d32fdc7e81ac7f5582f7bc26739 Mon Sep 17 00:00:00 2001 From: Anush Date: Fri, 19 Mar 2021 10:02:35 -0700 Subject: [PATCH] Fix saved searches alert_track datatype (#64) Co-authored-by: ajayaraman --- client/models/saved_searches.go | 2 +- splunk/resource_splunk_saved_searches.go | 4 ++-- splunk/resource_splunk_saved_searches_test.go | 4 ++++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/client/models/saved_searches.go b/client/models/saved_searches.go index 537068c5..e66b551f 100644 --- a/client/models/saved_searches.go +++ b/client/models/saved_searches.go @@ -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"` diff --git a/splunk/resource_splunk_saved_searches.go b/splunk/resource_splunk_saved_searches.go index c4a3725b..dbe5e4eb 100644 --- a/splunk/resource_splunk_saved_searches.go +++ b/splunk/resource_splunk_saved_searches.go @@ -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." + @@ -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), diff --git a/splunk/resource_splunk_saved_searches_test.go b/splunk/resource_splunk_saved_searches_test.go index e0c481ce..82dbc91f 100644 --- a/splunk/resource_splunk_saved_searches_test.go +++ b/splunk/resource_splunk_saved_searches_test.go @@ -24,6 +24,7 @@ resource "splunk_saved_searches" "test" { action_email_subject = "Splunk Alert: $name$" action_email_to = "splunk@splunk.com" action_email_track_alert = true + alert_track = true dispatch_earliest_time = "rt-15m" dispatch_latest_time = "rt-0m" dispatch_index_earliest = "-10m" @@ -52,6 +53,7 @@ resource "splunk_saved_searches" "test" { action_email_subject = "Splunk Alert: $name$" action_email_to = "splunk@splunk.com" action_email_track_alert = true + alert_track = true dispatch_earliest_time = "rt-15m" dispatch_latest_time = "rt-0m" dispatch_index_earliest = "-20m" @@ -184,6 +186,7 @@ func TestAccSplunkSavedSearches(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "action_email_subject", "Splunk Alert: $name$"), resource.TestCheckResourceAttr(resourceName, "action_email_to", "splunk@splunk.com"), 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"), @@ -209,6 +212,7 @@ func TestAccSplunkSavedSearches(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "action_email_subject", "Splunk Alert: $name$"), resource.TestCheckResourceAttr(resourceName, "action_email_to", "splunk@splunk.com"), 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"),