@@ -235,6 +235,7 @@ func flattenRetentionPeriod(retentionPeriod *core.RetentionPeriod) types.List {
235
235
types .ObjectValueMust (
236
236
getRetentionPeriodAttrTypes (),
237
237
map [string ]attr.Value {
238
+ "strategy" : types .StringValue (retentionPeriod .Strategy ),
238
239
"quantity_to_keep" : types .Int64Value (int64 (retentionPeriod .QuantityToKeep )),
239
240
"should_keep_forever" : types .BoolValue (retentionPeriod .ShouldKeepForever ),
240
241
"unit" : types .StringValue (retentionPeriod .Unit ),
@@ -331,21 +332,30 @@ func expandRetentionPeriod(v types.List) *core.RetentionPeriod {
331
332
quantityToKeep = int32 (qty .ValueInt64 ())
332
333
}
333
334
334
- var shouldKeepForever bool
335
- if keep , ok := attrs ["should_keep_forever" ].(types.Bool ); ok && ! keep .IsNull () {
336
- shouldKeepForever = keep .ValueBool ()
337
- }
338
-
339
335
var unit string
340
336
if u , ok := attrs ["unit" ].(types.String ); ok && ! u .IsNull () {
341
337
unit = u .ValueString ()
342
338
}
343
339
344
- return core .NewRetentionPeriod (quantityToKeep , unit , shouldKeepForever )
340
+ var strategy string
341
+ if stgy , ok := attrs ["strategy" ].(types.String ); ok && ! stgy .IsNull () && ! stgy .IsUnknown () {
342
+ strategy = stgy .ValueString ()
343
+ } else if quantityToKeep > 0 {
344
+ strategy = core .RetentionStrategyCount
345
+ }
346
+
347
+ if strategy == core .RetentionStrategyForever {
348
+ return core .KeepForeverRetentionPeriod ()
349
+ } else if strategy == core .RetentionStrategyCount {
350
+ return core .CountBasedRetentionPeriod (quantityToKeep , unit )
351
+ } else {
352
+ return core .SpaceDefaultRetentionPeriod ()
353
+ }
345
354
}
346
355
347
356
func getRetentionPeriodAttrTypes () map [string ]attr.Type {
348
357
return map [string ]attr.Type {
358
+ "strategy" : types .StringType ,
349
359
"quantity_to_keep" : types .Int64Type ,
350
360
"should_keep_forever" : types .BoolType ,
351
361
"unit" : types .StringType ,
0 commit comments