Skip to content

Commit

Permalink
add custom Diff method to suppress diff when needed
Browse files Browse the repository at this point in the history
  • Loading branch information
vsinghal13 committed Aug 2, 2023
1 parent 19d6fca commit 241d7ba
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 15 deletions.
8 changes: 1 addition & 7 deletions sumologic/resource_sumologic_cloudwatch_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,8 @@ resource "sumologic_cloudwatch_source" "cloudwatch" {
type = "TagFilters"
namespace = "AWS/Route53"
tags = ["k1=v1"]
}
use_versioned_api = false
}
}
lifecycle {
ignore_changes = [
path["use_versioned_api"]
]
}
}
`, cName, cDescription, cCategory, sName, sDescription, sCategory, testAwsRoleArn)
}
3 changes: 1 addition & 2 deletions sumologic/resource_sumologic_gcp_metrics_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,9 @@ func testAccSumologicGcpMetricsSourceConfig(t *testing.T, cName, cDescription, c
service_name = "compute_instance_and_guests"
prefixes = ["%s" ,"compute.googleapis.com/guest/", "compute.googleapis.com/instance/"]
}
use_versioned_api = false
}
lifecycle {
ignore_changes = [authentication[0].private_key, path["use_versioned_api"]]
ignore_changes = [authentication[0].private_key]
}
}
`, cName, cDescription, cCategory, sName, sDescription, sCategory,
Expand Down
10 changes: 7 additions & 3 deletions sumologic/resource_sumologic_generic_polling_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,13 @@ func resourceSumologicGenericPollingSource() *schema.Resource {
Type: schema.TypeBool,
Optional: true,
Default: true,
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
contentType := d.Get("content_type").(string)
if contentType != "AwsS3Bucket" {
return true
}
return false
},
},
"path_expression": {
Type: schema.TypeString,
Expand Down Expand Up @@ -584,7 +591,6 @@ func getPollingPathSettings(d *schema.ResourceData) (PollingPath, error) {
}
pathSettings.SnsTopicOrSubscriptionArn = getPollingSnsTopicOrSubscriptionArn(d)
case "CloudWatchPath", "AwsInventoryPath":
pathSettings.UseVersionedApi = nil
pathSettings.Type = pathType
rawLimitToRegions := path["limit_to_regions"].([]interface{})
LimitToRegions := make([]string, 0, len(rawLimitToRegions))
Expand All @@ -607,7 +613,6 @@ func getPollingPathSettings(d *schema.ResourceData) (PollingPath, error) {
pathSettings.TagFilters = getPollingTagFilters(d)
}
case "AwsXRayPath":
pathSettings.UseVersionedApi = nil
pathSettings.Type = "AwsXRayPath"
rawLimitToRegions := path["limit_to_regions"].([]interface{})
LimitToRegions := make([]string, 0, len(rawLimitToRegions))
Expand All @@ -618,7 +623,6 @@ func getPollingPathSettings(d *schema.ResourceData) (PollingPath, error) {
}
pathSettings.LimitToRegions = LimitToRegions
case "GcpMetricsPath":
pathSettings.UseVersionedApi = nil
pathSettings.Type = pathType
addGcpMetricsPathSettings(&pathSettings, path)
default:
Expand Down
2 changes: 1 addition & 1 deletion sumologic/resource_sumologic_monitors_library_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func getMonitorBaseSchema() map[string]*schema.Schema {
ValidateFunc: validation.All(
validation.StringDoesNotContainAny("/"),
validation.StringMatch(regexp.MustCompile(`(?s)^[^\ ].*[^\ ]$`),
"name must not contain leading or trailing spaces"),
"name must not contain leading or trailing spaces"),
),
},

Expand Down
4 changes: 2 additions & 2 deletions sumologic/resource_sumologic_slo.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ func resourceSumologicSLO() *schema.Resource {
Schema: map[string]*schema.Schema{

"name": {
Type: schema.TypeString,
Required: true,
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringDoesNotContainAny("/"),
},
"description": {
Expand Down

0 comments on commit 241d7ba

Please sign in to comment.