Skip to content

Commit

Permalink
Merge 019b120 into 3a45f12
Browse files Browse the repository at this point in the history
  • Loading branch information
lholmquist committed Feb 9, 2018
2 parents 3a45f12 + 019b120 commit 7d87ea3
Show file tree
Hide file tree
Showing 22 changed files with 1,655 additions and 2,203 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ dist: trusty
language: node_js
node_js:
- "8"
- "7"
- "6"
- "9"
before_install:
- npm install -g npm
- npm install -g greenkeeper-lockfile@1
Expand Down
19 changes: 12 additions & 7 deletions lib/config-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,26 @@
*/

const privates = require('./private-map');
const openshiftConfigLoader = require('openshift-config-loader');

function load (settings) {
if (settings.config) {
return Promise.resolve(settings.config);
}

return openshiftConfigLoader(settings.openshiftConfigLoader);
}

// Takes a config object as JSON
// Returns a promise
function loadConfig (client, config) {
return new Promise((resolve, reject) => {
if (!config) {
return reject(new Error('Config object is require'));
}

function loadConfig (client) {
return load(client.settings).then((config) => {
client.apiUrl = `${config.cluster}/oapi/${config.apiVersion}`;
client.kubeUrl = `${config.cluster}/api/${config.apiVersion}`;

privates.get(client).config = config;

resolve(client);
return client;
});
}

Expand Down
6 changes: 2 additions & 4 deletions lib/openshift-rest-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ function bindModule (client, input) {
}
}

function openshiftClient (config, settings) {
settings = settings || {};

function openshiftClient (settings = {}) {
const data = {};
const client = {};

Expand Down Expand Up @@ -82,7 +80,7 @@ function openshiftClient (config, settings) {
privates.set(client, data);

// Maybe load the config here?
return loadConfig(client, config);
return loadConfig(client);
}

module.exports = exports = openshiftClient;
23 changes: 9 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"email": "lholmqui@redhat.com"
},
"engines": {
"node": ">= 4.0.0"
"node": ">= 8.0.0"
},
"repository": {
"type": "git",
Expand All @@ -39,6 +39,7 @@
"bugs": "https://github.com/bucharest-gold/openshift-rest-client/issues",
"license": "Apache-2.0",
"dependencies": {
"openshift-config-loader": "^0.4.0",
"request": "^2.83.0"
},
"devDependencies": {
Expand All @@ -55,7 +56,6 @@
"nock": "^9.0.14",
"nsp": "^3.1.0",
"nyc": "^11.1.0",
"openshift-config-loader": "^0.3.0",
"proxyquire": "^1.8.0",
"tap-spec": "^4.1.1",
"tape": "^4.6.3"
Expand Down
Loading

0 comments on commit 7d87ea3

Please sign in to comment.