@@ -23,6 +23,7 @@ import (
23
23
svcapitypes "github.com/aws-controllers-k8s/kafka-controller/apis/v1alpha1"
24
24
ackcompare "github.com/aws-controllers-k8s/runtime/pkg/compare"
25
25
ackcondition "github.com/aws-controllers-k8s/runtime/pkg/condition"
26
+ ackerr "github.com/aws-controllers-k8s/runtime/pkg/errors"
26
27
ackrequeue "github.com/aws-controllers-k8s/runtime/pkg/requeue"
27
28
ackrtlog "github.com/aws-controllers-k8s/runtime/pkg/runtime/log"
28
29
ackutil "github.com/aws-controllers-k8s/runtime/pkg/util"
@@ -354,6 +355,16 @@ func (rm *resourceManager) getAssociatedScramSecrets(
354
355
return res , err
355
356
}
356
357
358
+ type unprocessedSecret struct {
359
+ errorCode string
360
+ errorMessage string
361
+ secretArn string
362
+ }
363
+
364
+ func (us unprocessedSecret ) String () string {
365
+ return fmt .Sprintf ("ErrorCode: %s, ErrorMessage %s, SecretArn: %s" , us .errorCode , us .errorMessage , us .secretArn )
366
+ }
367
+
357
368
// batchAssociateScramSecret associates the supplied scram secrets to the supplied Cluster
358
369
// resource
359
370
func (rm * resourceManager ) batchAssociateScramSecret (
@@ -367,14 +378,27 @@ func (rm *resourceManager) batchAssociateScramSecret(
367
378
368
379
input := & svcsdk.BatchAssociateScramSecretInput {}
369
380
input .ClusterArn = (* string )(r .ko .Status .ACKResourceMetadata .ARN )
370
- // Convert []*string to []string
371
- unrefSecrets := make ([]string , len (secretARNs ))
372
- for i , s := range secretARNs {
373
- unrefSecrets [i ] = * s
374
- }
375
- input .SecretArnList = unrefSecrets
376
- _ , err = rm .sdkapi .BatchAssociateScramSecret (ctx , input )
381
+ input .SecretArnList = aws .ToStringSlice (secretARNs )
382
+ resp , err := rm .sdkapi .BatchAssociateScramSecret (ctx , input )
377
383
rm .metrics .RecordAPICall ("UPDATE" , "BatchAssociateScramSecret" , err )
384
+ if err != nil {
385
+ return err
386
+ }
387
+
388
+ if len (resp .UnprocessedScramSecrets ) > 0 {
389
+ unprocessedSecrets := []unprocessedSecret {}
390
+ for _ , uss := range resp .UnprocessedScramSecrets {
391
+ us := unprocessedSecret {
392
+ errorCode : aws .ToString (uss .ErrorCode ),
393
+ errorMessage : aws .ToString (uss .ErrorMessage ),
394
+ secretArn : aws .ToString (uss .SecretArn ),
395
+ }
396
+ unprocessedSecrets = append (unprocessedSecrets , us )
397
+ }
398
+
399
+ return ackerr .NewTerminalError (fmt .Errorf ("Cant attach secret arns: %v" , unprocessedSecrets ))
400
+ }
401
+
378
402
return err
379
403
}
380
404
0 commit comments