Skip to content

Commit

Permalink
Fix having zero retention with flex (#2716)
Browse files Browse the repository at this point in the history
  • Loading branch information
Prepager authored Dec 13, 2024
1 parent 146c518 commit 1ebba65
Show file tree
Hide file tree
Showing 4 changed files with 300 additions and 29 deletions.
8 changes: 6 additions & 2 deletions datadog/resource_datadog_logs_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ func buildDatadogIndexUpdateRequest(d *schema.ResourceData) *datadogV1.LogsIndex
if v, ok := d.GetOk("disable_daily_limit"); ok {
ddIndex.SetDisableDailyLimit(v.(bool))
}
if v, ok := d.GetOk("retention_days"); ok {
ddIndex.SetNumRetentionDays(int64(v.(int)))
if !d.GetRawConfig().GetAttr("retention_days").IsNull() {
ddIndex.SetNumRetentionDays(int64(d.Get("retention_days").(int)))
}
if v, ok := d.GetOk("flex_retention_days"); ok {
ddIndex.SetNumFlexLogsRetentionDays(int64(v.(int)))
Expand Down Expand Up @@ -314,6 +314,10 @@ func buildDatadogIndexCreateRequest(d *schema.ResourceData) *datadogV1.LogsIndex
}
if v, ok := d.GetOk("flex_retention_days"); ok {
ddIndex.SetNumFlexLogsRetentionDays(int64(v.(int)))
if _, isRetentionSet := ddIndex.GetNumRetentionDaysOk(); !isRetentionSet {
// NOTE: Null retention is not an acceptable value on creation with flex. Must be explicitly 0.
ddIndex.SetNumRetentionDays(0)
}
}
ddIndex.ExclusionFilters = *buildDatadogExclusionFilters(d.Get("exclusion_filter").([]interface{}))
return &ddIndex
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-09-10T14:21:35.751535-04:00
2024-12-11T13:34:22.866712+01:00
Loading

0 comments on commit 1ebba65

Please sign in to comment.