enable triton credentials from credentials.json

credentials can be set not only using ENV variables,
but also with credentials.json (if it is found)
This commit is contained in:
Sérgio Ramos 2016-10-20 02:13:04 +01:00
parent b1b4dcfdf5
commit a29f544d69
2 changed files with 15 additions and 7 deletions

View File

@ -1,10 +1,4 @@
const credentials = {
url: process.env.SDC_URL,
account: process.env.SDC_ACCOUNT,
user: process.env.SDC_USER || '',
keyId: process.env.SDC_KEY_ID,
};
const credentials = require('../credentials');
const auth = require('smartdc-auth');
const cloudapi = require('triton/lib/cloudapi2');
const bunyan = require('bunyan');

View File

@ -0,0 +1,14 @@
const json = (() => {
try {
return require('../credentials.json');
} catch (err) {
return {};
}
})();
module.exports = {
url: process.env.SDC_URL || json.url || '',
account: process.env.SDC_ACCOUNT || json.account || '',
user: process.env.SDC_USER || json.user || '',
keyId: process.env.SDC_KEY_ID || json.keyId || ''
};