Compare commits

...

1 Commits

Author SHA1 Message Date
Bennett Buchanan 6a231a7c23 FT: Replication to AWS 2017-10-04 13:50:11 -07:00
3 changed files with 15 additions and 11 deletions

View File

@ -60,6 +60,7 @@ module.exports = class ObjectMD {
destination: '',
storageClass: '',
role: '',
storageType: '',
},
'dataStoreName': '',
};
@ -586,14 +587,15 @@ module.exports = class ObjectMD {
* @return {ObjectMD} itself
*/
setReplicationInfo(replicationInfo) {
const { status, content, destination, storageClass, role } =
replicationInfo;
const { status, content, destination, storageClass, role,
storageType } = replicationInfo;
this._data.replicationInfo = {
status,
content,
destination,
storageClass: storageClass || '',
role,
storageType: storageType || '',
};
return this;
}

View File

@ -148,10 +148,10 @@ class ReplicationConfiguration {
}
const role = parsedRole[0];
const rolesArr = role.split(',');
if (rolesArr.length !== 2) {
if (rolesArr.length > 2) {
return errors.InvalidArgument.customizeDescription(
'Invalid Role specified in replication configuration: ' +
'Role must be a comma-separated list of two IAM roles');
'Invalid Role specified in replication configuration: Role ' +
'cannot be a comma-separated list of more than two IAM roles');
}
const invalidRole = rolesArr.find(r => !this._isValidRoleARN(r));
if (invalidRole !== undefined) {
@ -262,7 +262,9 @@ class ReplicationConfiguration {
return errors.InvalidRequest.customizeDescription(
'Rule Id must be unique');
}
this._configIDs.push(id);
if (id !== undefined) {
this._configIDs.push(id);
}
return undefined;
}
@ -278,7 +280,10 @@ class ReplicationConfiguration {
const replicationEndpoints = this._config.replicationEndpoints
.map(endpoint => endpoint.site);
const locationConstraints =
Object.keys(this._config.locationConstraints);
return replicationEndpoints.includes(storageClass) ||
locationConstraints.includes(storageClass) ||
validStorageClasses.includes(storageClass);
}
@ -326,11 +331,6 @@ class ReplicationConfiguration {
return errors.InvalidArgument
.customizeDescription('The specified bucket is not valid');
}
// We can replicate objects only to one destination bucket.
if (this._destination && this._destination !== bucketARN) {
return errors.InvalidRequest.customizeDescription(
'The destination bucket must be same for all rules');
}
this._destination = bucketARN;
return undefined;
}

View File

@ -79,6 +79,7 @@ describe('ObjectMD class setters/getters', () => {
destination: '',
storageClass: '',
role: '',
storageType: '',
}],
['ReplicationInfo', {
status: 'PENDING',
@ -87,6 +88,7 @@ describe('ObjectMD class setters/getters', () => {
storageClass: 'STANDARD',
role: 'arn:aws:iam::account-id:role/src-resource,' +
'arn:aws:iam::account-id:role/dest-resource',
storageType: 'aws_s3',
}],
['DataStoreName', null, ''],
].forEach(test => {