Skip to content

Commit 4b4d910

Browse files
committed
use generic polling source instead of regular one
1 parent 9487ae1 commit 4b4d910

File tree

3 files changed

+25
-24
lines changed

3 files changed

+25
-24
lines changed

sumologic/provider.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ func Provider() terraform.ResourceProvider {
4444
"sumologic_s3_source": resourceSumologicGenericPollingSource(),
4545
"sumologic_s3_audit_source": resourceSumologicGenericPollingSource(),
4646
"sumologic_cloudwatch_source": resourceSumologicGenericPollingSource(),
47+
"sumologic_aws_xray_source": resourceSumologicGenericPollingSource(),
4748
"sumologic_cloudtrail_source": resourceSumologicGenericPollingSource(),
4849
"sumologic_elb_source": resourceSumologicGenericPollingSource(),
4950
"sumologic_cloudfront_source": resourceSumologicGenericPollingSource(),

sumologic/resource_sumologic_generic_polling_source.go

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ func resourceSumologicGenericPollingSource() *schema.Resource {
1919
}
2020

2121
pollingSource.Schema["content_type"] = &schema.Schema{
22-
Type: schema.TypeString,
23-
Required: true,
24-
ForceNew: true,
25-
ValidateFunc: validation.StringInSlice([]string{"AwsS3Bucket", "AwsElbBucket", "AwsCloudFrontBucket", "AwsCloudTrailBucket", "AwsS3AuditBucket", "AwsCloudWatch"}, false),
22+
Type: schema.TypeString,
23+
Required: true,
24+
ForceNew: true,
25+
ValidateFunc: validation.StringInSlice([]string{"AwsS3Bucket", "AwsElbBucket", "AwsCloudFrontBucket",
26+
"AwsCloudTrailBucket", "AwsS3AuditBucket", "AwsCloudWatch", "AwsXRay"}, false),
2627
}
2728
pollingSource.Schema["scan_interval"] = &schema.Schema{
2829
Type: schema.TypeInt,
@@ -73,9 +74,10 @@ func resourceSumologicGenericPollingSource() *schema.Resource {
7374
Elem: &schema.Resource{
7475
Schema: map[string]*schema.Schema{
7576
"type": {
76-
Type: schema.TypeString,
77-
Required: true,
78-
ValidateFunc: validation.StringInSlice([]string{"S3BucketPathExpression", "CloudWatchPath"}, false),
77+
Type: schema.TypeString,
78+
Required: true,
79+
ValidateFunc: validation.StringInSlice([]string{"S3BucketPathExpression", "CloudWatchPath",
80+
"AwsXRayPath"}, false),
7981
},
8082
"bucket_name": {
8183
Type: schema.TypeString,
@@ -327,6 +329,14 @@ func getPollingPathSettings(d *schema.ResourceData) PollingPath {
327329
pathSettings.LimitToRegions = LimitToRegions
328330
pathSettings.LimitToNamespaces = LimitToNamespaces
329331
pathSettings.TagFilters = getPollingTagFilters(d)
332+
case "AwsXRayPath":
333+
pathSettings.Type = "AwsXRayPath"
334+
rawLimitToRegions := path["limit_to_regions"].([]interface{})
335+
LimitToRegions := make([]string, len(rawLimitToRegions))
336+
for i, v := range rawLimitToRegions {
337+
LimitToRegions[i] = v.(string)
338+
}
339+
pathSettings.LimitToRegions = LimitToRegions
330340
default:
331341
log.Printf("[ERROR] Unknown resourceType in path: %v", pathType)
332342
}

sumologic/resource_sumologic_polling_source.go

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@ func resourceSumologicPollingSource() *schema.Resource {
2121
"We are deprecating the generic sumologic polling source and in turn creating individual sources for each of the content_type currently supported."
2222

2323
pollingSource.Schema["content_type"] = &schema.Schema{
24-
Type: schema.TypeString,
25-
Required: true,
26-
ForceNew: true,
27-
ValidateFunc: validation.StringInSlice([]string{"AwsS3Bucket", "AwsElbBucket", "AwsCloudFrontBucket",
28-
"AwsCloudTrailBucket", "AwsS3AuditBucket", "AwsCloudWatch", "AwsXRay"}, false),
24+
Type: schema.TypeString,
25+
Required: true,
26+
ForceNew: true,
27+
ValidateFunc: validation.StringInSlice([]string{"AwsS3Bucket", "AwsElbBucket", "AwsCloudFrontBucket", "AwsCloudTrailBucket", "AwsS3AuditBucket", "AwsCloudWatch"}, false),
2928
}
3029
pollingSource.Schema["scan_interval"] = &schema.Schema{
3130
Type: schema.TypeInt,
@@ -76,10 +75,9 @@ func resourceSumologicPollingSource() *schema.Resource {
7675
Elem: &schema.Resource{
7776
Schema: map[string]*schema.Schema{
7877
"type": {
79-
Type: schema.TypeString,
80-
Required: true,
81-
ValidateFunc: validation.StringInSlice([]string{"S3BucketPathExpression", "CloudWatchPath",
82-
"AwsXRayPath"}, false),
78+
Type: schema.TypeString,
79+
Required: true,
80+
ValidateFunc: validation.StringInSlice([]string{"S3BucketPathExpression", "CloudWatchPath"}, false),
8381
},
8482
"bucket_name": {
8583
Type: schema.TypeString,
@@ -331,14 +329,6 @@ func getPathSettings(d *schema.ResourceData) PollingPath {
331329
pathSettings.LimitToRegions = LimitToRegions
332330
pathSettings.LimitToNamespaces = LimitToNamespaces
333331
pathSettings.TagFilters = getTagFilters(d)
334-
case "AwsXRayPath":
335-
pathSettings.Type = "AwsXRayPath"
336-
rawLimitToRegions := path["limit_to_regions"].([]interface{})
337-
LimitToRegions := make([]string, len(rawLimitToRegions))
338-
for i, v := range rawLimitToRegions {
339-
LimitToRegions[i] = v.(string)
340-
}
341-
pathSettings.LimitToRegions = LimitToRegions
342332
default:
343333
log.Printf("[ERROR] Unknown resourceType in path: %v", pathType)
344334
}

0 commit comments

Comments
 (0)