@@ -300,103 +300,9 @@ function hdClientLocationConstraintAssert(configHd) {
300300 return hdclientFields ;
301301}
302302
303- function azureArchiveLocationConstraintAssert ( locationObj ) {
304- const checkedFields = [
305- 'azureContainerName' ,
306- 'azureStorageEndpoint' ,
307- ] ;
308- if ( Object . keys ( locationObj . details ) . length === 0 ||
309- ! checkedFields . every ( field => field in locationObj . details ) ) {
310- return ;
311- }
312- const {
313- azureContainerName,
314- azureStorageEndpoint,
315- } = locationObj . details ;
316- const stringFields = [
317- azureContainerName ,
318- azureStorageEndpoint ,
319- ] ;
320- stringFields . forEach ( field => {
321- assert ( typeof field === 'string' ,
322- `bad config: ${ field } must be a string` ) ;
323- } ) ;
324-
325- let hasAuthMethod = false ;
326- if ( locationObj . details . sasToken !== undefined ) {
327- assert ( typeof locationObj . details . sasToken === 'string' ,
328- `bad config: ${ locationObj . details . sasToken } must be a string` ) ;
329- hasAuthMethod = true ;
330- }
331-
332- if ( locationObj . details . azureStorageAccountName !== undefined &&
333- locationObj . details . azureStorageAccessKey !== undefined ) {
334- assert ( typeof locationObj . details . azureStorageAccountName === 'string' ,
335- `bad config: ${ locationObj . details . azureStorageAccountName } must be a string` ) ;
336- assert ( typeof locationObj . details . azureStorageAccessKey === 'string' ,
337- `bad config: ${ locationObj . details . azureStorageAccessKey } must be a string` ) ;
338- assert ( ! hasAuthMethod , 'Multiple authentication methods are not allowed' ) ;
339- hasAuthMethod = true ;
340- }
341-
342- if ( locationObj . details . tenantId !== undefined &&
343- locationObj . details . clientId !== undefined &&
344- locationObj . details . clientKey !== undefined ) {
345- assert ( typeof locationObj . details . tenantId === 'string' ,
346- `bad config: ${ locationObj . details . tenantId } must be a string` ) ;
347- assert ( typeof locationObj . details . clientId === 'string' ,
348- `bad config: ${ locationObj . details . clientId } must be a string` ) ;
349- assert ( typeof locationObj . details . clientKey === 'string' ,
350- `bad config: ${ locationObj . details . clientKey } must be a string` ) ;
351- assert ( ! hasAuthMethod , 'Multiple authentication methods are not allowed' ) ;
352- hasAuthMethod = true ;
353- }
354- assert ( hasAuthMethod , 'Missing authentication method' ) ;
355- }
356-
357- function dmfLocationConstraintAssert ( locationObj ) {
358- const checkedFields = [
359- 'endpoint' ,
360- 'username' ,
361- 'password' ,
362- 'repoId' ,
363- 'nsId' ,
364- ] ;
365- if ( Object . keys ( locationObj . details ) . length === 0 ||
366- ! checkedFields . every ( field => field in locationObj . details ) ) {
367- return ;
368- }
369- const {
370- endpoint,
371- username,
372- password,
373- repoId,
374- nsId,
375- } = locationObj . details ;
376- const stringFields = [
377- endpoint ,
378- username ,
379- password ,
380- nsId ,
381- ] ;
382- stringFields . forEach ( field => {
383- assert ( typeof field === 'string' ,
384- `bad config: ${ field } must be a string` ) ;
385- } ) ;
386- assert . strictEqual ( Array . isArray ( repoId ) , true ) ;
387- repoId . forEach ( rId => {
388- assert ( typeof rId === 'string' ,
389- `bad config: ${ rId } must be a string` ) ;
390- } ) ;
391- assert ( repoId . every (
392- r => typeof r === 'string' ) ,
393- 'bad config: each repoId must be a string' ,
394- ) ;
395- }
396-
397303function locationConstraintAssert ( locationConstraints ) {
398304 const supportedBackends = [
399- 'mem' , 'file' , 'scality' , 'mongodb' , 'dmf' , 'azure_archive' , ' tlp',
305+ 'mem' , 'file' , 'scality' , 'mongodb' , 'tlp' ,
400306 ] . concat ( Object . keys ( validExternalBackends ) ) ;
401307 assert ( typeof locationConstraints === 'object' ,
402308 'bad config: locationConstraints must be an object' ) ;
@@ -467,6 +373,15 @@ function locationConstraintAssert(locationConstraints) {
467373 assert ( typeof details . credentials . secretKey === 'string' ,
468374 'bad config: credentials must include secretKey as string' ) ;
469375 }
376+
377+ if ( locationConstraints [ l ] . type === 'tlp' ) {
378+ // should have no detail
379+ assert ( Object . keys ( locationConstraints [ l ] . details ) . length === 0 ) ;
380+
381+ // should be a cold location
382+ assert ( locationConstraints [ l ] . isCold === true ) ;
383+ }
384+
470385 if ( process . env . CI_CEPH === 'true' ) {
471386 // eslint-disable-next-line no-param-reassign
472387 locationConstraints [ l ] . details . https = false ;
@@ -505,15 +420,6 @@ function locationConstraintAssert(locationConstraints) {
505420 if ( locationConstraints [ l ] . type === 'gcp' ) {
506421 gcpLocationConstraintAssert ( l , locationConstraints [ l ] ) ;
507422 }
508- if ( locationConstraints [ l ] . type === 'dmf' ) {
509- dmfLocationConstraintAssert ( locationConstraints [ l ] ) ;
510- }
511- if ( locationConstraints [ l ] . type === 'azure_archive' ) {
512- azureArchiveLocationConstraintAssert ( locationConstraints [ l ] ) ;
513- }
514- if ( locationConstraints [ l ] . type === 'tlp' ) {
515- assert ( Object . keys ( locationConstraints [ l ] . details ) . length === 0 ) ;
516- }
517423 if ( locationConstraints [ l ] . type === 'pfs' ) {
518424 assert ( typeof details . pfsDaemonEndpoint === 'object' ,
519425 'bad config: pfsDaemonEndpoint is mandatory and must be an object' ) ;
@@ -2009,6 +1915,5 @@ module.exports = {
20091915 bucketNotifAssert,
20101916 azureGetStorageAccountName,
20111917 azureGetLocationCredentials,
2012- azureArchiveLocationConstraintAssert,
20131918 parseSupportedLifecycleRules,
20141919} ;
0 commit comments