From 85dee35b43d6801f7755ad7a36ef89a246665d42 Mon Sep 17 00:00:00 2001 From: Bennett Buchanan Date: Thu, 15 Feb 2018 14:22:51 -0800 Subject: [PATCH] FT: Add changes for replication with GCP --- lib/api/apiUtils/object/getReplicationInfo.js | 3 ++- tests/locationConfig/locationConfigLegacy.json | 11 +++++++++++ tests/unit/api/objectReplicationMD.js | 2 ++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/api/apiUtils/object/getReplicationInfo.js b/lib/api/apiUtils/object/getReplicationInfo.js index 3eb0934922..ec4fcd26a5 100644 --- a/lib/api/apiUtils/object/getReplicationInfo.js +++ b/lib/api/apiUtils/object/getReplicationInfo.js @@ -1,4 +1,5 @@ const s3config = require('../../../Config').config; +const constants = require('../../../../constants'); function _getBackend(objectMD, site) { const backends = objectMD ? objectMD.replicationInfo.backends : []; @@ -35,7 +36,7 @@ function _getReplicationInfo(rule, replicationConfig, content, operationType, const storageClasses = _getStorageClasses(rule); storageClasses.forEach(storageClass => { const location = s3config.locationConstraints[storageClass]; - if (location && ['aws_s3', 'azure'].includes(location.type)) { + if (location && constants.replicationBackends[location.type]) { storageTypes.push(location.type); } backends.push(_getBackend(objectMD, storageClass)); diff --git a/tests/locationConfig/locationConfigLegacy.json b/tests/locationConfig/locationConfigLegacy.json index c6a12c8371..612885165f 100644 --- a/tests/locationConfig/locationConfigLegacy.json +++ b/tests/locationConfig/locationConfigLegacy.json @@ -103,5 +103,16 @@ "bucketMatch": false, "azureContainerName": "s3test" } + }, + "gcpbackend": { + "type": "gcp", + "legacyAwsBehavior": true, + "details": { + "gcpEndpoint": "storage.googleapis.com", + "bucketName": "zenko-gcp-bucket", + "mpuBucketName": "zenko-gcp-mpu", + "bucketMatch": true, + "credentialsProfile": "google" + } } } diff --git a/tests/unit/api/objectReplicationMD.js b/tests/unit/api/objectReplicationMD.js index 4f0aee8efb..7a80188cb6 100644 --- a/tests/unit/api/objectReplicationMD.js +++ b/tests/unit/api/objectReplicationMD.js @@ -474,10 +474,12 @@ describe('Replication object MD without bucket replication config', () => { ['awsbackend', 'azurebackend', + 'gcpbackend', 'awsbackend,azurebackend'].forEach(backend => { const storageTypeMap = { 'awsbackend': 'aws_s3', 'azurebackend': 'azure', + 'gcpbackend': 'gcp', 'awsbackend,azurebackend': 'aws_s3,azure', }; const storageType = storageTypeMap[backend];