@@ -32,20 +32,30 @@ import (
32
32
)
33
33
34
34
var (
35
- ErrTableDeleting = fmt .Errorf ("Table in '%v' state, cannot be modified or deleted" , svcsdk .TableStatusDeleting )
36
- ErrTableCreating = fmt .Errorf ("Table in '%v' state, cannot be modified or deleted" , svcsdk .TableStatusCreating )
37
- ErrTableUpdating = fmt .Errorf ("Table in '%v' state, cannot be modified or deleted" , svcsdk .TableStatusUpdating )
38
- ErrTableGSIsUpdating = fmt .Errorf ("Table GSIs in '%v' state, cannot be modified or deleted" , svcsdk .IndexStatusCreating )
35
+ ErrTableDeleting = fmt .Errorf (
36
+ "Table in '%v' state, cannot be modified or deleted" ,
37
+ svcsdk .TableStatusDeleting ,
38
+ )
39
+ ErrTableCreating = fmt .Errorf (
40
+ "Table in '%v' state, cannot be modified or deleted" ,
41
+ svcsdk .TableStatusCreating ,
42
+ )
43
+ ErrTableUpdating = fmt .Errorf (
44
+ "Table in '%v' state, cannot be modified or deleted" ,
45
+ svcsdk .TableStatusUpdating ,
46
+ )
47
+ ErrTableGSIsUpdating = fmt .Errorf (
48
+ "Table GSIs in '%v' state, cannot be modified or deleted" ,
49
+ svcsdk .IndexStatusCreating ,
50
+ )
39
51
)
40
52
41
- var (
42
- // TerminalStatuses are the status strings that are terminal states for a
43
- // DynamoDB table
44
- TerminalStatuses = []v1alpha1.TableStatus_SDK {
45
- v1alpha1 .TableStatus_SDK_ARCHIVING ,
46
- v1alpha1 .TableStatus_SDK_DELETING ,
47
- }
48
- )
53
+ // TerminalStatuses are the status strings that are terminal states for a
54
+ // DynamoDB table
55
+ var TerminalStatuses = []v1alpha1.TableStatus_SDK {
56
+ v1alpha1 .TableStatus_SDK_ARCHIVING ,
57
+ v1alpha1 .TableStatus_SDK_DELETING ,
58
+ }
49
59
50
60
var DefaultTTLEnabledValue = false
51
61
@@ -124,7 +134,10 @@ func (rm *resourceManager) customUpdateTable(
124
134
defer func (err error ) { exit (err ) }(err )
125
135
126
136
if immutableFieldChanges := rm .getImmutableFieldChanges (delta ); len (immutableFieldChanges ) > 0 {
127
- msg := fmt .Sprintf ("Immutable Spec fields have been modified: %s" , strings .Join (immutableFieldChanges , "," ))
137
+ msg := fmt .Sprintf (
138
+ "Immutable Spec fields have been modified: %s" ,
139
+ strings .Join (immutableFieldChanges , "," ),
140
+ )
128
141
return nil , ackerr .NewTerminalError (fmt .Errorf (msg ))
129
142
}
130
143
@@ -187,6 +200,13 @@ func (rm *resourceManager) customUpdateTable(
187
200
}
188
201
}
189
202
203
+ if delta .DifferentAt ("Spec.ContinuousBackups" ) {
204
+ err = rm .syncContinuousBackup (ctx , desired )
205
+ if err != nil {
206
+ return nil , fmt .Errorf ("cannot update table %v" , err )
207
+ }
208
+ }
209
+
190
210
// We want to update fast fields first
191
211
// Then attributes
192
212
// then GSI
@@ -202,7 +222,8 @@ func (rm *resourceManager) customUpdateTable(
202
222
}
203
223
case delta .DifferentAt ("Spec.GlobalSecondaryIndexes" ) && delta .DifferentAt ("Spec.AttributeDefinitions" ):
204
224
if err := rm .syncTableGlobalSecondaryIndexes (ctx , latest , desired ); err != nil {
205
- if awsErr , ok := ackerr .AWSError (err ); ok && awsErr .Code () == "LimitExceededException" {
225
+ if awsErr , ok := ackerr .AWSError (err ); ok &&
226
+ awsErr .Code () == "LimitExceededException" {
206
227
return nil , requeueWaitGSIReady
207
228
}
208
229
return nil , err
@@ -257,13 +278,17 @@ func (rm *resourceManager) newUpdateTablePayload(
257
278
input .ProvisionedThroughput = & svcsdk.ProvisionedThroughput {}
258
279
if r .ko .Spec .ProvisionedThroughput != nil {
259
280
if r .ko .Spec .ProvisionedThroughput .ReadCapacityUnits != nil {
260
- input .ProvisionedThroughput .ReadCapacityUnits = aws .Int64 (* r .ko .Spec .ProvisionedThroughput .ReadCapacityUnits )
281
+ input .ProvisionedThroughput .ReadCapacityUnits = aws .Int64 (
282
+ * r .ko .Spec .ProvisionedThroughput .ReadCapacityUnits ,
283
+ )
261
284
} else {
262
285
input .ProvisionedThroughput .ReadCapacityUnits = aws .Int64 (0 )
263
286
}
264
287
265
288
if r .ko .Spec .ProvisionedThroughput .WriteCapacityUnits != nil {
266
- input .ProvisionedThroughput .WriteCapacityUnits = aws .Int64 (* r .ko .Spec .ProvisionedThroughput .WriteCapacityUnits )
289
+ input .ProvisionedThroughput .WriteCapacityUnits = aws .Int64 (
290
+ * r .ko .Spec .ProvisionedThroughput .WriteCapacityUnits ,
291
+ )
267
292
} else {
268
293
input .ProvisionedThroughput .WriteCapacityUnits = aws .Int64 (0 )
269
294
}
@@ -277,8 +302,11 @@ func (rm *resourceManager) newUpdateTablePayload(
277
302
StreamEnabled : aws .Bool (* r .ko .Spec .StreamSpecification .StreamEnabled ),
278
303
}
279
304
// Only set streamViewType when streamSpefication is enabled and streamViewType is non-nil.
280
- if * r .ko .Spec .StreamSpecification .StreamEnabled && r .ko .Spec .StreamSpecification .StreamViewType != nil {
281
- input .StreamSpecification .StreamViewType = aws .String (* r .ko .Spec .StreamSpecification .StreamViewType )
305
+ if * r .ko .Spec .StreamSpecification .StreamEnabled &&
306
+ r .ko .Spec .StreamSpecification .StreamViewType != nil {
307
+ input .StreamSpecification .StreamViewType = aws .String (
308
+ * r .ko .Spec .StreamSpecification .StreamViewType ,
309
+ )
282
310
}
283
311
} else {
284
312
input .StreamSpecification = & svcsdk.StreamSpecification {
@@ -317,7 +345,9 @@ func (rm *resourceManager) syncTableSSESpecification(
317
345
input .SSESpecification .SSEType = aws .String (* r .ko .Spec .SSESpecification .SSEType )
318
346
}
319
347
if r .ko .Spec .SSESpecification .KMSMasterKeyID != nil {
320
- input .SSESpecification .KMSMasterKeyId = aws .String (* r .ko .Spec .SSESpecification .KMSMasterKeyID )
348
+ input .SSESpecification .KMSMasterKeyId = aws .String (
349
+ * r .ko .Spec .SSESpecification .KMSMasterKeyID ,
350
+ )
321
351
}
322
352
}
323
353
} else {
@@ -350,13 +380,17 @@ func (rm *resourceManager) syncTableProvisionedThroughput(
350
380
}
351
381
if r .ko .Spec .ProvisionedThroughput != nil {
352
382
if r .ko .Spec .ProvisionedThroughput .ReadCapacityUnits != nil {
353
- input .ProvisionedThroughput .ReadCapacityUnits = aws .Int64 (* r .ko .Spec .ProvisionedThroughput .ReadCapacityUnits )
383
+ input .ProvisionedThroughput .ReadCapacityUnits = aws .Int64 (
384
+ * r .ko .Spec .ProvisionedThroughput .ReadCapacityUnits ,
385
+ )
354
386
} else {
355
387
input .ProvisionedThroughput .ReadCapacityUnits = aws .Int64 (0 )
356
388
}
357
389
358
390
if r .ko .Spec .ProvisionedThroughput .WriteCapacityUnits != nil {
359
- input .ProvisionedThroughput .WriteCapacityUnits = aws .Int64 (* r .ko .Spec .ProvisionedThroughput .WriteCapacityUnits )
391
+ input .ProvisionedThroughput .WriteCapacityUnits = aws .Int64 (
392
+ * r .ko .Spec .ProvisionedThroughput .WriteCapacityUnits ,
393
+ )
360
394
} else {
361
395
input .ProvisionedThroughput .WriteCapacityUnits = aws .Int64 (0 )
362
396
}
@@ -395,6 +429,12 @@ func (rm *resourceManager) setResourceAdditionalFields(
395
429
ko .Spec .TimeToLive = ttlSpec
396
430
}
397
431
432
+ if pitrSpec , err := rm .getResourcePointInTimeRecoveryWithContext (ctx , ko .Spec .TableName ); err != nil {
433
+ return err
434
+ } else {
435
+ ko .Spec .ContinuousBackups = pitrSpec
436
+ }
437
+
398
438
return nil
399
439
}
400
440
@@ -403,11 +443,14 @@ func customPreCompare(
403
443
a * resource ,
404
444
b * resource ,
405
445
) {
406
-
407
446
if ackcompare .HasNilDifference (a .ko .Spec .SSESpecification , b .ko .Spec .SSESpecification ) {
408
447
if a .ko .Spec .SSESpecification != nil && b .ko .Spec .SSESpecification == nil {
409
448
if * a .ko .Spec .SSESpecification .Enabled {
410
- delta .Add ("Spec.SSESpecification" , a .ko .Spec .SSESpecification , b .ko .Spec .SSESpecification )
449
+ delta .Add (
450
+ "Spec.SSESpecification" ,
451
+ a .ko .Spec .SSESpecification ,
452
+ b .ko .Spec .SSESpecification ,
453
+ )
411
454
}
412
455
} else {
413
456
delta .Add ("Spec.SSESpecification" , a .ko .Spec .SSESpecification , b .ko .Spec .SSESpecification )
@@ -447,23 +490,35 @@ func customPreCompare(
447
490
}
448
491
449
492
if len (a .ko .Spec .AttributeDefinitions ) != len (b .ko .Spec .AttributeDefinitions ) {
450
- delta .Add ("Spec.AttributeDefinitions" , a .ko .Spec .AttributeDefinitions , b .ko .Spec .AttributeDefinitions )
493
+ delta .Add (
494
+ "Spec.AttributeDefinitions" ,
495
+ a .ko .Spec .AttributeDefinitions ,
496
+ b .ko .Spec .AttributeDefinitions ,
497
+ )
451
498
} else if a .ko .Spec .AttributeDefinitions != nil && b .ko .Spec .AttributeDefinitions != nil {
452
499
if ! equalAttributeDefinitions (a .ko .Spec .AttributeDefinitions , b .ko .Spec .AttributeDefinitions ) {
453
500
delta .Add ("Spec.AttributeDefinitions" , a .ko .Spec .AttributeDefinitions , b .ko .Spec .AttributeDefinitions )
454
501
}
455
502
}
456
503
457
504
if len (a .ko .Spec .GlobalSecondaryIndexes ) != len (b .ko .Spec .GlobalSecondaryIndexes ) {
458
- delta .Add ("Spec.GlobalSecondaryIndexes" , a .ko .Spec .GlobalSecondaryIndexes , b .ko .Spec .GlobalSecondaryIndexes )
505
+ delta .Add (
506
+ "Spec.GlobalSecondaryIndexes" ,
507
+ a .ko .Spec .GlobalSecondaryIndexes ,
508
+ b .ko .Spec .GlobalSecondaryIndexes ,
509
+ )
459
510
} else if a .ko .Spec .GlobalSecondaryIndexes != nil && b .ko .Spec .GlobalSecondaryIndexes != nil {
460
511
if ! equalGlobalSecondaryIndexesArrays (a .ko .Spec .GlobalSecondaryIndexes , b .ko .Spec .GlobalSecondaryIndexes ) {
461
512
delta .Add ("Spec.GlobalSecondaryIndexes" , a .ko .Spec .GlobalSecondaryIndexes , b .ko .Spec .GlobalSecondaryIndexes )
462
513
}
463
514
}
464
515
465
516
if len (a .ko .Spec .LocalSecondaryIndexes ) != len (b .ko .Spec .LocalSecondaryIndexes ) {
466
- delta .Add ("Spec.LocalSecondaryIndexes" , a .ko .Spec .LocalSecondaryIndexes , b .ko .Spec .LocalSecondaryIndexes )
517
+ delta .Add (
518
+ "Spec.LocalSecondaryIndexes" ,
519
+ a .ko .Spec .LocalSecondaryIndexes ,
520
+ b .ko .Spec .LocalSecondaryIndexes ,
521
+ )
467
522
} else if a .ko .Spec .LocalSecondaryIndexes != nil && b .ko .Spec .LocalSecondaryIndexes != nil {
468
523
if ! equalLocalSecondaryIndexesArrays (a .ko .Spec .LocalSecondaryIndexes , b .ko .Spec .LocalSecondaryIndexes ) {
469
524
delta .Add ("Spec.LocalSecondaryIndexes" , a .ko .Spec .LocalSecondaryIndexes , b .ko .Spec .LocalSecondaryIndexes )
@@ -614,7 +669,10 @@ func equalLocalSecondaryIndexes(
614
669
if ! equalStrings (a .Projection .ProjectionType , b .Projection .ProjectionType ) {
615
670
return false
616
671
}
617
- if ! ackcompare .SliceStringPEqual (a .Projection .NonKeyAttributes , b .Projection .NonKeyAttributes ) {
672
+ if ! ackcompare .SliceStringPEqual (
673
+ a .Projection .NonKeyAttributes ,
674
+ b .Projection .NonKeyAttributes ,
675
+ ) {
618
676
return false
619
677
}
620
678
}
0 commit comments