Skip to content

Commit df1a8e4

Browse files
committed
Merge branch 'feature/BB-195-support-passing-notification-destination-creds-by-environement-variable' into q/8.4
2 parents 80bce55 + c8aadb1 commit df1a8e4

File tree

4 files changed

+42
-4
lines changed

4 files changed

+42
-4
lines changed

extensions/notification/NotificationConfigValidator.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,26 @@
11
const joi = require('joi');
22

3+
const authSchema = joi.object({
4+
type: joi.string(),
5+
ssl: joi.boolean(),
6+
protocol: joi.string(),
7+
ca: joi.string(),
8+
client: joi.string(),
9+
key: joi.string(),
10+
keyPassword: joi.string(),
11+
keytab: joi.string(),
12+
principal: joi.string(),
13+
serviceName: joi.string(),
14+
});
15+
316
const destinationSchema = joi.object({
417
resource: joi.string().required(),
518
type: joi.string().required(),
619
host: joi.string().required(),
720
port: joi.number().required(),
821
internalTopic: joi.string(),
922
topic: joi.string().required(),
10-
auth: joi.object().default({}),
23+
auth: authSchema.default({}),
1124
});
1225

1326
const joiSchema = joi.object({

extensions/notification/queueProcessor/QueueProcessor.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ class QueueProcessor extends EventEmitter {
3434
* @param {String} destinationConfig.host - destination host
3535
* @param {String} destinationConfig.auth - destination auth configuration
3636
* @param {String} destinationId - resource name/id of destination
37+
* @param {Object} destinationAuth - destination authentication config
3738
*/
38-
constructor(mongoConfig, kafkaConfig, notifConfig, destinationId) {
39+
constructor(mongoConfig, kafkaConfig, notifConfig, destinationId,
40+
destinationAuth) {
3941
super();
4042
this.mongoConfig = mongoConfig;
4143
this.kafkaConfig = kafkaConfig;
@@ -45,6 +47,11 @@ class QueueProcessor extends EventEmitter {
4547
= notifConfig.destinations.find(dest => dest.resource === destinationId);
4648
assert(this.destinationConfig, `Invalid destination argument "${destinationId}".` +
4749
' Destination could not be found in destinations defined');
50+
// overwriting destination auth config
51+
// if it was passed by env var
52+
if (destinationAuth) {
53+
this.destinationConfig.auth = destinationAuth;
54+
}
4855
this.bnConfigManager = null;
4956
this._consumer = null;
5057
this._destination = null;

extensions/notification/queueProcessor/task.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,26 @@ werelogs.configure({
1717
try {
1818
const destination = process.argv[2];
1919
assert(destination, 'task must be started with a destination as argument');
20+
// get destination auth config from environment variables
21+
let destinationAuth = {
22+
type: process.env.TYPE,
23+
ssl: process.env.SSL === 'true',
24+
protocol: process.env.PROTOCOL,
25+
ca: process.env.CA,
26+
client: process.env.CLIENT,
27+
key: process.env.KEY,
28+
keyPassword: process.env.KEY_PASSWORD,
29+
keytab: process.env.KEYTAB,
30+
principal: process.env.PRINCIPAL,
31+
serviceName: process.env.SERVICE_NAME,
32+
};
33+
const isDestinationAuthEmpty = Object.values(destinationAuth)
34+
.every(x => !x);
35+
if (isDestinationAuthEmpty) {
36+
destinationAuth = null;
37+
}
2038
const queueProcessor = new QueueProcessor(
21-
mongoConfig, kafkaConfig, notifConfig, destination);
39+
mongoConfig, kafkaConfig, notifConfig, destination, destinationAuth);
2240
queueProcessor.start();
2341
} catch (err) {
2442
log.error('error starting notification queue processor task', {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "backbeat",
3-
"version": "8.3.17",
3+
"version": "8.4.4",
44
"description": "Asynchronous queue and job manager",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)