11const joi = require ( 'joi' ) ;
22const { probeServerJoi } = require ( '../../lib/config/configItems.joi' ) ;
33
4- const authSchema = joi . object ( {
5- type : joi . string ( ) ,
6- ssl : joi . boolean ( ) ,
7- protocol : joi . string ( ) ,
4+ const sslSchema = joi . object ( {
5+ ssl : joi . boolean ( ) . default ( false ) ,
86 ca : joi . string ( ) ,
97 client : joi . string ( ) ,
108 key : joi . string ( ) ,
119 keyPassword : joi . string ( ) ,
12- keytab : joi . string ( ) ,
13- principal : joi . string ( ) ,
14- serviceName : joi . string ( ) ,
1510} ) ;
1611
12+ const saslAuthSchema = ssl . append ( {
13+ protocol : joi . string ( ) . valid ( 'SASL_PLAINTEXT' , 'SASL_SSL' ) . required ( ) ,
14+ } ) ;
15+
16+ const kerberosAuthSchema = sasl . append ( {
17+ type : joi . string ( ) . valid ( 'kerberos' ) . required ( ) ,
18+ keytab : joi . string ( ) . required ( ) ,
19+ principal : joi . string ( ) . required ( ) ,
20+ serviceName : joi . string ( ) . required ( ) ,
21+ } ) ;
22+
23+ const basicAuthSchema = sasl . append ( {
24+ type : joi . string ( ) . valid ( 'basic' ) . required ( ) ,
25+ credentialsFile : joi . string ( ) . required ( ) ,
26+ } ) ;
27+
28+ const credentialsFileSchema = joi . object ( {
29+ username : joi . string ( ) . required ( ) ,
30+ password : joi . string ( ) . required ( ) ,
31+ } ) ;
32+
33+ const authSchema = joi . alternatives ( ) . try ( ssl , kerberos , basic ) . default ( { } ) ;
34+
1735const destinationSchema = joi . object ( {
1836 resource : joi . string ( ) . required ( ) ,
1937 type : joi . string ( ) . required ( ) ,
2038 host : joi . string ( ) . required ( ) ,
2139 port : joi . number ( ) . optional ( ) ,
2240 internalTopic : joi . string ( ) ,
2341 topic : joi . string ( ) . required ( ) ,
24- auth : authSchema . default ( { } ) ,
42+ auth : authSchema ,
2543 requiredAcks : joi . number ( ) . when ( 'type' , {
2644 is : joi . string ( ) . not ( 'kafka' ) ,
2745 then : joi . forbidden ( ) ,
@@ -39,10 +57,10 @@ const joiSchema = joi.object({
3957 monitorNotificationFailures : joi . boolean ( ) . default ( true ) ,
4058 notificationFailedTopic : joi . string ( ) . optional ( ) ,
4159 zookeeperPath : joi . string ( ) . optional ( ) ,
42- queueProcessor : {
60+ queueProcessor : joi . object ( {
4361 groupId : joi . string ( ) . required ( ) ,
4462 concurrency : joi . number ( ) . greater ( 0 ) . default ( 1000 ) ,
45- } ,
63+ } ) ,
4664 destinations : joi . array ( ) . items ( destinationSchema ) . default ( [ ] ) ,
4765 // TODO: BB-625 reset to being required after supporting probeserver in S3C
4866 // for bucket notification proceses
@@ -59,4 +77,7 @@ function configValidator(backbeatConfig, extConfig) {
5977 return validatedConfig ;
6078}
6179
62- module . exports = configValidator ;
80+ module . exports = {
81+ NotificationConfigValidator : configValidator ,
82+ authSchema,
83+ } ;
0 commit comments