Compare commits

...

1 Commits

Author SHA1 Message Date
Alexander Chan 16add154cc CLDSRV-227: support dmf location type 2022-06-15 13:57:05 -07:00
1 changed files with 34 additions and 1 deletions

View File

@ -191,9 +191,39 @@ function hdClientLocationConstraintAssert(configHd) {
return hdclientFields; return hdclientFields;
} }
function dmfLocationConstraintAssert(location, locationObj) {
const { isCold } = locationObj;
const {
endpoint,
password,
username,
repoId,
nsId,
} = locationObj.details;
assert(isCold === true, 'bad config: invalid isCold setting for dmf type');
assert(repoId.length > 0, 'bad config: empty repoId');
assert(Array.isArray(repoId)
&& repoId.every(id => typeof id === 'string'),
'bad config: repoId must be an array of strings');
const stringFields = {
endpoint,
password,
username,
nsId,
};
Object.keys(stringFields).forEach(field => {
if (stringFields[field] !== undefined) {
assert(typeof stringFields[field] === 'string',
`bad config: ${field} must be a string`);
}
});
}
function locationConstraintAssert(locationConstraints) { function locationConstraintAssert(locationConstraints) {
const supportedBackends = const supportedBackends =
['mem', 'file', 'scality', ['mem', 'file', 'scality', 'dmf',
'mongodb'].concat(Object.keys(validExternalBackends)); 'mongodb'].concat(Object.keys(validExternalBackends));
assert(typeof locationConstraints === 'object', assert(typeof locationConstraints === 'object',
'bad config: locationConstraints must be an object'); 'bad config: locationConstraints must be an object');
@ -302,6 +332,9 @@ function locationConstraintAssert(locationConstraints) {
if (locationConstraints[l].type === 'gcp') { if (locationConstraints[l].type === 'gcp') {
gcpLocationConstraintAssert(l, locationConstraints[l]); gcpLocationConstraintAssert(l, locationConstraints[l]);
} }
if (locationConstraints[l].type === 'dmf') {
dmfLocationConstraintAssert(l, locationConstraints[l]);
}
if (locationConstraints[l].type === 'pfs') { if (locationConstraints[l].type === 'pfs') {
assert(typeof details.pfsDaemonEndpoint === 'object', assert(typeof details.pfsDaemonEndpoint === 'object',
'bad config: pfsDaemonEndpoint is mandatory and must be an object'); 'bad config: pfsDaemonEndpoint is mandatory and must be an object');