Skip to content

Commit cbc2c78

Browse files
committed
add custom Diff method to suppress diff when needed
1 parent 19d6fca commit cbc2c78

5 files changed

+11
-14
lines changed

sumologic/resource_sumologic_cloudwatch_source_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,7 @@ resource "sumologic_cloudwatch_source" "cloudwatch" {
182182
namespace = "AWS/Route53"
183183
tags = ["k1=v1"]
184184
}
185-
use_versioned_api = false
186185
}
187-
lifecycle {
188-
ignore_changes = [
189-
path["use_versioned_api"]
190-
]
191-
}
192186
}
193187
`, cName, cDescription, cCategory, sName, sDescription, sCategory, testAwsRoleArn)
194188
}

sumologic/resource_sumologic_gcp_metrics_source_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,9 @@ func testAccSumologicGcpMetricsSourceConfig(t *testing.T, cName, cDescription, c
250250
service_name = "compute_instance_and_guests"
251251
prefixes = ["%s" ,"compute.googleapis.com/guest/", "compute.googleapis.com/instance/"]
252252
}
253-
use_versioned_api = false
254253
}
255254
lifecycle {
256-
ignore_changes = [authentication[0].private_key, path["use_versioned_api"]]
255+
ignore_changes = [authentication[0].private_key]
257256
}
258257
}
259258
`, cName, cDescription, cCategory, sName, sDescription, sCategory,

sumologic/resource_sumologic_generic_polling_source.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,13 @@ func resourceSumologicGenericPollingSource() *schema.Resource {
129129
Type: schema.TypeBool,
130130
Optional: true,
131131
Default: true,
132+
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
133+
contentType := d.Get("content_type").(string)
134+
if contentType != "AwsS3Bucket" {
135+
return true
136+
}
137+
return false
138+
},
132139
},
133140
"path_expression": {
134141
Type: schema.TypeString,
@@ -584,7 +591,6 @@ func getPollingPathSettings(d *schema.ResourceData) (PollingPath, error) {
584591
}
585592
pathSettings.SnsTopicOrSubscriptionArn = getPollingSnsTopicOrSubscriptionArn(d)
586593
case "CloudWatchPath", "AwsInventoryPath":
587-
pathSettings.UseVersionedApi = nil
588594
pathSettings.Type = pathType
589595
rawLimitToRegions := path["limit_to_regions"].([]interface{})
590596
LimitToRegions := make([]string, 0, len(rawLimitToRegions))
@@ -607,7 +613,6 @@ func getPollingPathSettings(d *schema.ResourceData) (PollingPath, error) {
607613
pathSettings.TagFilters = getPollingTagFilters(d)
608614
}
609615
case "AwsXRayPath":
610-
pathSettings.UseVersionedApi = nil
611616
pathSettings.Type = "AwsXRayPath"
612617
rawLimitToRegions := path["limit_to_regions"].([]interface{})
613618
LimitToRegions := make([]string, 0, len(rawLimitToRegions))
@@ -618,7 +623,6 @@ func getPollingPathSettings(d *schema.ResourceData) (PollingPath, error) {
618623
}
619624
pathSettings.LimitToRegions = LimitToRegions
620625
case "GcpMetricsPath":
621-
pathSettings.UseVersionedApi = nil
622626
pathSettings.Type = pathType
623627
addGcpMetricsPathSettings(&pathSettings, path)
624628
default:

sumologic/resource_sumologic_monitors_library_monitor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func getMonitorBaseSchema() map[string]*schema.Schema {
3333
ValidateFunc: validation.All(
3434
validation.StringDoesNotContainAny("/"),
3535
validation.StringMatch(regexp.MustCompile(`(?s)^[^\ ].*[^\ ]$`),
36-
"name must not contain leading or trailing spaces"),
36+
"name must not contain leading or trailing spaces"),
3737
),
3838
},
3939

sumologic/resource_sumologic_slo.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ func resourceSumologicSLO() *schema.Resource {
164164
Schema: map[string]*schema.Schema{
165165

166166
"name": {
167-
Type: schema.TypeString,
168-
Required: true,
167+
Type: schema.TypeString,
168+
Required: true,
169169
ValidateFunc: validation.StringDoesNotContainAny("/"),
170170
},
171171
"description": {

0 commit comments

Comments
 (0)