@@ -258,9 +258,6 @@ func (r *ReconcilePerconaServerMongoDBBackup) getPBMStorage(ctx context.Context,
258
258
}
259
259
return azure .New (azureConf , nil )
260
260
case cr .Status .S3 != nil :
261
- if cr .Status .S3 .CredentialsSecret == "" {
262
- return nil , errors .New ("no s3 credentials specified for the secret name" )
263
- }
264
261
s3Conf := s3.Conf {
265
262
Region : cr .Status .S3 .Region ,
266
263
EndpointURL : cr .Status .S3 .EndpointURL ,
@@ -271,9 +268,16 @@ func (r *ReconcilePerconaServerMongoDBBackup) getPBMStorage(ctx context.Context,
271
268
StorageClass : cr .Status .S3 .StorageClass ,
272
269
InsecureSkipTLSVerify : cr .Status .S3 .InsecureSkipTLSVerify ,
273
270
}
274
- s3secret , err := secret (ctx , r .client , cr .Namespace , cr .Status .S3 .CredentialsSecret )
275
- if err != nil {
276
- return nil , errors .Wrap (err , "getting s3 credentials secret name" )
271
+
272
+ if cr .Status .S3 .CredentialsSecret != "" {
273
+ s3secret , err := secret (ctx , r .client , cr .Namespace , cr .Status .S3 .CredentialsSecret )
274
+ if err != nil {
275
+ return nil , errors .Wrap (err , "getting s3 credentials secret name" )
276
+ }
277
+ s3Conf .Credentials = s3.Credentials {
278
+ AccessKeyID : string (s3secret .Data [backup .AWSAccessKeySecretKey ]),
279
+ SecretAccessKey : string (s3secret .Data [backup .AWSSecretAccessKeySecretKey ]),
280
+ }
277
281
}
278
282
279
283
if len (cr .Status .S3 .ServerSideEncryption .SSECustomerAlgorithm ) != 0 {
@@ -319,10 +323,6 @@ func (r *ReconcilePerconaServerMongoDBBackup) getPBMStorage(ctx context.Context,
319
323
}
320
324
}
321
325
322
- s3Conf .Credentials = s3.Credentials {
323
- AccessKeyID : string (s3secret .Data [backup .AWSAccessKeySecretKey ]),
324
- SecretAccessKey : string (s3secret .Data [backup .AWSSecretAccessKeySecretKey ]),
325
- }
326
326
return s3 .New (s3Conf , nil )
327
327
default :
328
328
return nil , errors .New ("no storage info in backup status" )
0 commit comments