Skip to content

Commit c875468

Browse files
committed
Merge pull request #379 from telefonicaid/task/newEnvironmentVariables
ADD New environment variables
2 parents bb92da7 + a4c63fc commit c875468

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

CHANGES_NEXT_RELEASE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@
2222
- Fix Endpoint attribute not stored in mongo (#369)
2323
- Fix Add a prefix for all the environment variables (#375)
2424
- Assess command_result field (#374)
25+
- Environment IOTA_MONGO_REPLICASET missing (#378)
2526
- Add TimeInstant processing plugin (#380)
26-

lib/commonConfig.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,11 @@ function processEnvironmentVariables() {
5656
'IOTA_IOTAM_PATH',
5757
'IOTA_IOTAM_PROTOCOL',
5858
'IOTA_IOTAM_DESCRIPTION',
59+
'IOTA_DEFAULT_RESOURCE',
5960
'IOTA_MONGO_HOST',
6061
'IOTA_MONGO_PORT',
61-
'IOTA_MONGO_DB'
62+
'IOTA_MONGO_DB',
63+
'IOTA_MONGO_REPLICASET'
6264
],
6365
iotamVariables = [
6466
'IOTA_IOTAM_HOST',
@@ -70,7 +72,8 @@ function processEnvironmentVariables() {
7072
mongoVariables = [
7173
'IOTA_MONGO_HOST',
7274
'IOTA_MONGO_PORT',
73-
'IOTA_MONGO_DB'
75+
'IOTA_MONGO_DB',
76+
'IOTA_MONGO_REPLICASET'
7477
];
7578

7679
for (var i = 0; i < environmentVariables.length; i++) {
@@ -113,6 +116,10 @@ function processEnvironmentVariables() {
113116
config.timestamp = process.env.IOTA_TIMESTAMP === 'true';
114117
}
115118

119+
if (process.env.IOTA_DEFAULT_RESOURCE) {
120+
config.defaultResource = process.env.IOTA_DEFAULT_RESOURCE;
121+
}
122+
116123
if (anyIsSet(iotamVariables)) {
117124
config.iotManager = {};
118125
}
@@ -152,6 +159,10 @@ function processEnvironmentVariables() {
152159
if (process.env.IOTA_MONGO_DB) {
153160
config.mongodb.db = process.env.IOTA_MONGO_DB;
154161
}
162+
163+
if (process.env.IOTA_MONGO_REPLICASET) {
164+
config.mongodb.replicaSet = process.env.IOTA_MONGO_REPLICASET;
165+
}
155166
}
156167

157168
function setConfig(newConfig) {

test/unit/general/startup-test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ describe('Startup tests', function() {
110110
process.env.IOTA_MONGO_HOST = 'mongohost';
111111
process.env.IOTA_MONGO_PORT = '5555';
112112
process.env.IOTA_MONGO_DB = 'themongodb';
113+
process.env.IOTA_MONGO_REPLICASET = 'customReplica';
114+
process.env.IOTA_DEFAULT_RESOURCE = '/iot/custom';
113115

114116
nock.cleanAll();
115117

@@ -135,6 +137,8 @@ describe('Startup tests', function() {
135137
delete process.env.IOTA_MONGO_HOST;
136138
delete process.env.IOTA_MONGO_PORT;
137139
delete process.env.IOTA_MONGO_DB;
140+
delete process.env.IOTA_MONGO_REPLICASET;
141+
delete process.env.IOTA_DEFAULT_RESOURCE;
138142
});
139143

140144
afterEach(function(done) {
@@ -156,9 +160,11 @@ describe('Startup tests', function() {
156160
config.getConfig().iotManager.path.should.equal('/iotampath');
157161
config.getConfig().iotManager.protocol.should.equal('PDI_PROTOCOL');
158162
config.getConfig().iotManager.description.should.equal('The IoTAM Protocol');
163+
config.getConfig().defaultResource.should.equal('/iot/custom');
159164
config.getConfig().mongodb.host.should.equal('mongohost');
160165
config.getConfig().mongodb.port.should.equal('5555');
161166
config.getConfig().mongodb.db.should.equal('themongodb');
167+
config.getConfig().mongodb.replicaSet.should.equal('customReplica');
162168
done();
163169
});
164170
});

0 commit comments

Comments
 (0)