@@ -195,8 +195,7 @@ export default class ReplicationConfiguration {
195
195
const invalidRole = rolesArr . find ( ( r ) => ! this . _isValidRoleARN ( r ) ) ;
196
196
if ( invalidRole !== undefined ) {
197
197
return errorInstances . InvalidArgument . customizeDescription (
198
- 'Invalid Role specified in replication configuration: ' +
199
- `'${ invalidRole } '`
198
+ `Invalid Role specified in replication configuration: '${ invalidRole } '`
200
199
) ;
201
200
}
202
201
this . _role = role ;
@@ -269,8 +268,7 @@ export default class ReplicationConfiguration {
269
268
}
270
269
if ( prefix . length > 1024 ) {
271
270
return errorInstances . InvalidArgument . customizeDescription (
272
- 'Rule prefix ' +
273
- 'cannot be longer than maximum allowed key length of 1024'
271
+ 'Rule prefix cannot be longer than maximum allowed key length of 1024'
274
272
) ;
275
273
}
276
274
// Each Prefix in a list of rules must not overlap. For example, two
@@ -280,7 +278,7 @@ export default class ReplicationConfiguration {
280
278
const used = this . _configPrefixes [ i ] ;
281
279
if ( prefix . startsWith ( used ) || used . startsWith ( prefix ) ) {
282
280
return errorInstances . InvalidRequest . customizeDescription (
283
- ' Found ' + ` overlapping prefixes '${ used } ' and '${ prefix } '`
281
+ ` Found overlapping prefixes '${ used } ' and '${ prefix } '`
284
282
) ;
285
283
}
286
284
}
@@ -296,13 +294,13 @@ export default class ReplicationConfiguration {
296
294
const id = rule . ID && rule . ID [ 0 ] ;
297
295
if ( id && id . length > RULE_ID_LIMIT ) {
298
296
return errorInstances . InvalidArgument . customizeDescription (
299
- 'Rule Id cannot be greater than 255'
297
+ 'Rule ID length cannot be greater than 255'
300
298
) ;
301
299
}
302
300
// Each ID in a list of rules must be unique.
303
301
if ( id && this . _configIDs . includes ( id ) ) {
304
302
return errorInstances . InvalidRequest . customizeDescription (
305
- 'Rule Id must be unique '
303
+ 'Duplicate Rule ID '
306
304
) ;
307
305
}
308
306
if ( id !== undefined ) {
@@ -324,14 +322,13 @@ export default class ReplicationConfiguration {
324
322
replicationEndpoints [ 0 ] ;
325
323
// StorageClass is optional.
326
324
if ( destination . StorageClass === undefined ) {
327
- this . _hasScalityDestination = defaultEndpoint . type === undefined ;
325
+ this . _hasScalityDestination = ( defaultEndpoint && defaultEndpoint . type === undefined ) ;
328
326
return undefined ;
329
327
}
330
328
const storageClasses = destination . StorageClass [ 0 ] . split ( ',' ) ;
331
329
const isValidStorageClass = storageClasses . every ( ( storageClass ) => {
332
330
if ( validStorageClasses . includes ( storageClass ) ) {
333
- this . _hasScalityDestination =
334
- defaultEndpoint . type === undefined ;
331
+ this . _hasScalityDestination = ( defaultEndpoint && defaultEndpoint . type === undefined ) ;
335
332
return true ;
336
333
}
337
334
const endpoint = replicationEndpoints . find (
@@ -344,7 +341,7 @@ export default class ReplicationConfiguration {
344
341
if ( ! this . _hasScalityDestination ) {
345
342
// If any endpoint does not have a type, then we know it is
346
343
// a Scality destination.
347
- this . _hasScalityDestination = endpoint . type === undefined ;
344
+ this . _hasScalityDestination = ( endpoint . type === undefined ) ;
348
345
}
349
346
return true ;
350
347
}
@@ -396,7 +393,7 @@ export default class ReplicationConfiguration {
396
393
// We can replicate objects only to one destination bucket.
397
394
if ( this . _destination && this . _destination !== bucketARN ) {
398
395
return errorInstances . InvalidRequest . customizeDescription (
399
- 'The destination bucket must be same for all rules'
396
+ 'The destination bucket must be the same for all rules'
400
397
) ;
401
398
}
402
399
this . _destination = bucketARN ;
@@ -427,6 +424,11 @@ export default class ReplicationConfiguration {
427
424
if ( err ) {
428
425
return err ;
429
426
}
427
+ const { replicationEndpoints } = this . _config ;
428
+ if ( replicationEndpoints . length === 0 ) {
429
+ return errors . InvalidRequest . customizeDescription (
430
+ 'No configured replication endpoint' ) ;
431
+ }
430
432
return this . _parseRole ( ) ;
431
433
}
432
434
0 commit comments