@@ -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,14 @@ func (rm *resourceManager) customUpdateTable(
187
200
}
188
201
}
189
202
203
+ if delta .DifferentAt ("Spec.ContinuousBackups" ) ||
204
+ delta .DifferentAt ("Spec.ContinuousBackups.PointInTimeRecoveryEnabled" ) {
205
+ err = rm .syncContinuousBackup (ctx , desired )
206
+ if err != nil {
207
+ return nil , fmt .Errorf ("cannot update table %v" , err )
208
+ }
209
+ }
210
+
190
211
// We want to update fast fields first
191
212
// Then attributes
192
213
// then GSI
@@ -202,7 +223,8 @@ func (rm *resourceManager) customUpdateTable(
202
223
}
203
224
case delta .DifferentAt ("Spec.GlobalSecondaryIndexes" ) && delta .DifferentAt ("Spec.AttributeDefinitions" ):
204
225
if err := rm .syncTableGlobalSecondaryIndexes (ctx , latest , desired ); err != nil {
205
- if awsErr , ok := ackerr .AWSError (err ); ok && awsErr .Code () == "LimitExceededException" {
226
+ if awsErr , ok := ackerr .AWSError (err ); ok &&
227
+ awsErr .Code () == "LimitExceededException" {
206
228
return nil , requeueWaitGSIReady
207
229
}
208
230
return nil , err
@@ -257,13 +279,17 @@ func (rm *resourceManager) newUpdateTablePayload(
257
279
input .ProvisionedThroughput = & svcsdk.ProvisionedThroughput {}
258
280
if r .ko .Spec .ProvisionedThroughput != nil {
259
281
if r .ko .Spec .ProvisionedThroughput .ReadCapacityUnits != nil {
260
- input .ProvisionedThroughput .ReadCapacityUnits = aws .Int64 (* r .ko .Spec .ProvisionedThroughput .ReadCapacityUnits )
282
+ input .ProvisionedThroughput .ReadCapacityUnits = aws .Int64 (
283
+ * r .ko .Spec .ProvisionedThroughput .ReadCapacityUnits ,
284
+ )
261
285
} else {
262
286
input .ProvisionedThroughput .ReadCapacityUnits = aws .Int64 (0 )
263
287
}
264
288
265
289
if r .ko .Spec .ProvisionedThroughput .WriteCapacityUnits != nil {
266
- input .ProvisionedThroughput .WriteCapacityUnits = aws .Int64 (* r .ko .Spec .ProvisionedThroughput .WriteCapacityUnits )
290
+ input .ProvisionedThroughput .WriteCapacityUnits = aws .Int64 (
291
+ * r .ko .Spec .ProvisionedThroughput .WriteCapacityUnits ,
292
+ )
267
293
} else {
268
294
input .ProvisionedThroughput .WriteCapacityUnits = aws .Int64 (0 )
269
295
}
@@ -277,8 +303,11 @@ func (rm *resourceManager) newUpdateTablePayload(
277
303
StreamEnabled : aws .Bool (* r .ko .Spec .StreamSpecification .StreamEnabled ),
278
304
}
279
305
// 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 )
306
+ if * r .ko .Spec .StreamSpecification .StreamEnabled &&
307
+ r .ko .Spec .StreamSpecification .StreamViewType != nil {
308
+ input .StreamSpecification .StreamViewType = aws .String (
309
+ * r .ko .Spec .StreamSpecification .StreamViewType ,
310
+ )
282
311
}
283
312
} else {
284
313
input .StreamSpecification = & svcsdk.StreamSpecification {
@@ -317,7 +346,9 @@ func (rm *resourceManager) syncTableSSESpecification(
317
346
input .SSESpecification .SSEType = aws .String (* r .ko .Spec .SSESpecification .SSEType )
318
347
}
319
348
if r .ko .Spec .SSESpecification .KMSMasterKeyID != nil {
320
- input .SSESpecification .KMSMasterKeyId = aws .String (* r .ko .Spec .SSESpecification .KMSMasterKeyID )
349
+ input .SSESpecification .KMSMasterKeyId = aws .String (
350
+ * r .ko .Spec .SSESpecification .KMSMasterKeyID ,
351
+ )
321
352
}
322
353
}
323
354
} else {
@@ -350,13 +381,17 @@ func (rm *resourceManager) syncTableProvisionedThroughput(
350
381
}
351
382
if r .ko .Spec .ProvisionedThroughput != nil {
352
383
if r .ko .Spec .ProvisionedThroughput .ReadCapacityUnits != nil {
353
- input .ProvisionedThroughput .ReadCapacityUnits = aws .Int64 (* r .ko .Spec .ProvisionedThroughput .ReadCapacityUnits )
384
+ input .ProvisionedThroughput .ReadCapacityUnits = aws .Int64 (
385
+ * r .ko .Spec .ProvisionedThroughput .ReadCapacityUnits ,
386
+ )
354
387
} else {
355
388
input .ProvisionedThroughput .ReadCapacityUnits = aws .Int64 (0 )
356
389
}
357
390
358
391
if r .ko .Spec .ProvisionedThroughput .WriteCapacityUnits != nil {
359
- input .ProvisionedThroughput .WriteCapacityUnits = aws .Int64 (* r .ko .Spec .ProvisionedThroughput .WriteCapacityUnits )
392
+ input .ProvisionedThroughput .WriteCapacityUnits = aws .Int64 (
393
+ * r .ko .Spec .ProvisionedThroughput .WriteCapacityUnits ,
394
+ )
360
395
} else {
361
396
input .ProvisionedThroughput .WriteCapacityUnits = aws .Int64 (0 )
362
397
}
@@ -395,6 +430,12 @@ func (rm *resourceManager) setResourceAdditionalFields(
395
430
ko .Spec .TimeToLive = ttlSpec
396
431
}
397
432
433
+ if pitrSpec , err := rm .getResourcePointInTimeRecoveryWithContext (ctx , ko .Spec .TableName ); err != nil {
434
+ return err
435
+ } else {
436
+ ko .Spec .ContinuousBackups = pitrSpec
437
+ }
438
+
398
439
return nil
399
440
}
400
441
@@ -403,11 +444,14 @@ func customPreCompare(
403
444
a * resource ,
404
445
b * resource ,
405
446
) {
406
-
407
447
if ackcompare .HasNilDifference (a .ko .Spec .SSESpecification , b .ko .Spec .SSESpecification ) {
408
448
if a .ko .Spec .SSESpecification != nil && b .ko .Spec .SSESpecification == nil {
409
449
if * a .ko .Spec .SSESpecification .Enabled {
410
- delta .Add ("Spec.SSESpecification" , a .ko .Spec .SSESpecification , b .ko .Spec .SSESpecification )
450
+ delta .Add (
451
+ "Spec.SSESpecification" ,
452
+ a .ko .Spec .SSESpecification ,
453
+ b .ko .Spec .SSESpecification ,
454
+ )
411
455
}
412
456
} else {
413
457
delta .Add ("Spec.SSESpecification" , a .ko .Spec .SSESpecification , b .ko .Spec .SSESpecification )
@@ -447,23 +491,35 @@ func customPreCompare(
447
491
}
448
492
449
493
if len (a .ko .Spec .AttributeDefinitions ) != len (b .ko .Spec .AttributeDefinitions ) {
450
- delta .Add ("Spec.AttributeDefinitions" , a .ko .Spec .AttributeDefinitions , b .ko .Spec .AttributeDefinitions )
494
+ delta .Add (
495
+ "Spec.AttributeDefinitions" ,
496
+ a .ko .Spec .AttributeDefinitions ,
497
+ b .ko .Spec .AttributeDefinitions ,
498
+ )
451
499
} else if a .ko .Spec .AttributeDefinitions != nil && b .ko .Spec .AttributeDefinitions != nil {
452
500
if ! equalAttributeDefinitions (a .ko .Spec .AttributeDefinitions , b .ko .Spec .AttributeDefinitions ) {
453
501
delta .Add ("Spec.AttributeDefinitions" , a .ko .Spec .AttributeDefinitions , b .ko .Spec .AttributeDefinitions )
454
502
}
455
503
}
456
504
457
505
if len (a .ko .Spec .GlobalSecondaryIndexes ) != len (b .ko .Spec .GlobalSecondaryIndexes ) {
458
- delta .Add ("Spec.GlobalSecondaryIndexes" , a .ko .Spec .GlobalSecondaryIndexes , b .ko .Spec .GlobalSecondaryIndexes )
506
+ delta .Add (
507
+ "Spec.GlobalSecondaryIndexes" ,
508
+ a .ko .Spec .GlobalSecondaryIndexes ,
509
+ b .ko .Spec .GlobalSecondaryIndexes ,
510
+ )
459
511
} else if a .ko .Spec .GlobalSecondaryIndexes != nil && b .ko .Spec .GlobalSecondaryIndexes != nil {
460
512
if ! equalGlobalSecondaryIndexesArrays (a .ko .Spec .GlobalSecondaryIndexes , b .ko .Spec .GlobalSecondaryIndexes ) {
461
513
delta .Add ("Spec.GlobalSecondaryIndexes" , a .ko .Spec .GlobalSecondaryIndexes , b .ko .Spec .GlobalSecondaryIndexes )
462
514
}
463
515
}
464
516
465
517
if len (a .ko .Spec .LocalSecondaryIndexes ) != len (b .ko .Spec .LocalSecondaryIndexes ) {
466
- delta .Add ("Spec.LocalSecondaryIndexes" , a .ko .Spec .LocalSecondaryIndexes , b .ko .Spec .LocalSecondaryIndexes )
518
+ delta .Add (
519
+ "Spec.LocalSecondaryIndexes" ,
520
+ a .ko .Spec .LocalSecondaryIndexes ,
521
+ b .ko .Spec .LocalSecondaryIndexes ,
522
+ )
467
523
} else if a .ko .Spec .LocalSecondaryIndexes != nil && b .ko .Spec .LocalSecondaryIndexes != nil {
468
524
if ! equalLocalSecondaryIndexesArrays (a .ko .Spec .LocalSecondaryIndexes , b .ko .Spec .LocalSecondaryIndexes ) {
469
525
delta .Add ("Spec.LocalSecondaryIndexes" , a .ko .Spec .LocalSecondaryIndexes , b .ko .Spec .LocalSecondaryIndexes )
@@ -614,7 +670,10 @@ func equalLocalSecondaryIndexes(
614
670
if ! equalStrings (a .Projection .ProjectionType , b .Projection .ProjectionType ) {
615
671
return false
616
672
}
617
- if ! ackcompare .SliceStringPEqual (a .Projection .NonKeyAttributes , b .Projection .NonKeyAttributes ) {
673
+ if ! ackcompare .SliceStringPEqual (
674
+ a .Projection .NonKeyAttributes ,
675
+ b .Projection .NonKeyAttributes ,
676
+ ) {
618
677
return false
619
678
}
620
679
}
0 commit comments