Skip to content

Commit

Permalink
Suppress defaults when planning changes to jira service desk params
Browse files Browse the repository at this point in the history
As mentioned in #161, terraform plan shows changes to saved search
parameters action_jira_service_desk_param_jira_description and
action_jira_service_desk_param_jira_summary when using the defaults
for those parameters.

From what I can tell, the default values are computed server-side
by Splunk. I believe this change will suppress superfluous changes
to these Jira parameters, but may break in the future if the Splunk
-computed defaults were to change.
  • Loading branch information
cwjohnston committed Dec 12, 2024
1 parent 989dcef commit dcf45be
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions splunk/resource_splunk_saved_searches.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ import (
"github.com/splunk/terraform-provider-splunk/client/models"
)

func suppressDefault(defaultValue string) schema.SchemaDiffSuppressFunc {
return func(k, old, new string, d *schema.ResourceData) bool {
return old == defaultValue && new == ""
}
}

func savedSearches() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
Expand Down Expand Up @@ -673,6 +679,7 @@ func savedSearches() *schema.Resource {
Type: schema.TypeString,
Optional: true,
Description: "Jira Issue Summary or title",
DiffSuppressFunc: suppressDefault("Splunk Alert: $name$"),
},
"action_jira_service_desk_param_jira_priority": {
Type: schema.TypeString,
Expand All @@ -683,6 +690,7 @@ func savedSearches() *schema.Resource {
Type: schema.TypeString,
Optional: true,
Description: "Enter the description of issue created",
DiffSuppressFunc: suppressDefault("The alert condition for '$name$' was triggered."),
},
"action_jira_service_desk_param_jira_customfields": {
Type: schema.TypeString,
Expand Down Expand Up @@ -1483,14 +1491,18 @@ func savedSearchesRead(d *schema.ResourceData, meta interface{}) error {
if err = d.Set("action_jira_service_desk_param_jira_issue_type", entry.Content.ActionJiraServiceDeskParamJiraIssueType); err != nil {
return err
}
if err = d.Set("action_jira_service_desk_param_jira_summary", entry.Content.ActionJiraServiceDeskParamJiraSummary); err != nil {
return err
if entry.Content.ActionJiraServiceDeskParamJiraSummary != "Splunk Alert: $name$" {
if err = d.Set("action_jira_service_desk_param_jira_summary", entry.Content.ActionJiraServiceDeskParamJiraSummary); err != nil {
return err
}
}
if err = d.Set("action_jira_service_desk_param_jira_priority", entry.Content.ActionJiraServiceDeskParamJiraPriority); err != nil {
return err
}
if err = d.Set("action_jira_service_desk_param_jira_description", entry.Content.ActionJiraServiceDeskParamJiraDescription); err != nil {
return err
if entry.Content.ActionJiraServiceDeskParamJiraDescription != "The alert condition for '$name$' was triggered." {
if err = d.Set("action_jira_service_desk_param_jira_description", entry.Content.ActionJiraServiceDeskParamJiraDescription); err != nil {
return err
}
}
if err = d.Set("action_jira_service_desk_param_jira_customfields", entry.Content.ActionJiraServiceDeskParamJiraCustomfields); err != nil {
return err
Expand Down

0 comments on commit dcf45be

Please sign in to comment.