Skip to content

Commit

Permalink
Adding reusable method for boolean strings from ENV
Browse files Browse the repository at this point in the history
  • Loading branch information
phutchins committed Apr 27, 2017
1 parent 4f0846b commit cda7ebc
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,15 @@ var isConfigRS = function() {
return configSvrBool;
};

/**
* @returns boolean
*/
var stringToBool = function(boolStr) {
var isTrue = ( boolStr === 'true' ) || false;

return isTrue;
};

module.exports = {
namespace: process.env.KUBE_NAMESPACE,
username: process.env.MONGODB_USERNAME,
Expand All @@ -102,9 +111,9 @@ module.exports = {
loopSleepSeconds: process.env.MONGO_SIDECAR_SLEEP_SECONDS || 5,
unhealthySeconds: process.env.MONGO_SIDECAR_UNHEALTHY_SECONDS || 15,
mongoListenPort: process.env.MONGO_LISTEN_PORT || 27017,
mongoSSLEnabled: ( process.env.MONGO_SSL_ENABLED === 'true' ) || false,
mongoSSLAllowInvalidCertificates: ( process.env.MONGO_SSL_ALLOW_INVALID_CERTIFICATES === 'true' ) || true,
mongoSSLAllowInvalidHostnames: ( process.env.MONGO_SSL_ALLOW_INVALID_HOSTNAMES === 'true' ) || true,
mongoSSLEnabled: stringToBool(process.env.MONGO_SSL_ENABLED),
mongoSSLAllowInvalidCertificates: stringToBool(process.env.MONGO_SSL_ALLOW_INVALID_CERTIFICATES),
mongoSSLAllowInvalidHostnames: stringToBool(process.env.MONGO_SSL_ALLOW_INVALID_HOSTNAMES),
env: process.env.NODE_ENV || 'local',
mongoPodLabels: getMongoPodLabels(),
mongoPodLabelCollection: getMongoPodLabelCollection(),
Expand Down

0 comments on commit cda7ebc

Please sign in to comment.