Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

openshift-rest-client

Package Overview
Dependencies
Maintainers
4
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

openshift-rest-client - npm Package Compare versions

Comparing version 0.11.0 to 0.12.0-0

19

lib/config-loader.js

@@ -22,11 +22,16 @@ 'use strict';

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}`;

@@ -37,3 +42,3 @@ client.kubeUrl = `${config.cluster}/api/${config.apiVersion}`;

resolve(client);
return client;
});

@@ -40,0 +45,0 @@ }

@@ -54,5 +54,10 @@ 'use strict';

function openshiftClient (config, settings) {
settings = settings || {};
/**
@param {object} [settings] -
@param {object} [settings.config] - overrides the default openshift configuration
@param {object} [settings.openshiftConfigLoader] - settings to pass to the openshift-config-loader module
@param {object} [settings.request] - settings to pass to the request module
@returns {Promise} - Returns the Rest Client
*/
function openshiftClient (settings = {}) {
const data = {};

@@ -86,5 +91,5 @@ const client = {};

// Maybe load the config here?
return loadConfig(client, config);
return loadConfig(client);
}
module.exports = exports = openshiftClient;
{
"name": "openshift-rest-client",
"version": "0.11.0",
"version": "0.12.0-0",
"description": "Node.js client for developing with OpenShift",

@@ -33,3 +33,3 @@ "main": "index.js",

"engines": {
"node": ">= 4.0.0"
"node": ">= 8.0.0"
},

@@ -43,2 +43,3 @@ "repository": {

"dependencies": {
"openshift-config-loader": "^0.4.0",
"request": "^2.83.0"

@@ -52,3 +53,3 @@ },

"eslint-plugin-import": "^2.2.0",
"eslint-plugin-node": "^5.1.1",
"eslint-plugin-node": "^6.0.0",
"eslint-plugin-promise": "^3.5.0",

@@ -61,3 +62,2 @@ "eslint-plugin-react": "^7.0.0",

"nyc": "^11.1.0",
"openshift-config-loader": "^0.3.0",
"proxyquire": "^1.8.0",

@@ -64,0 +64,0 @@ "tap-spec": "^4.1.1",

@@ -9,33 +9,45 @@ [![Build Status](https://travis-ci.org/bucharest-gold/openshift-rest-client.svg?branch=master)](https://travis-ci.org/bucharest-gold/openshift-rest-client) [![Coverage Status](https://coveralls.io/repos/github/bucharest-gold/openshift-rest-client/badge.svg?branch=master)](https://coveralls.io/github/bucharest-gold/openshift-rest-client?branch=master)

### Usage
### Basic Usage
`npm install --save openshift-rest-client`
The client needs to be passed a `config` object with the follow properties:
Code:
{ apiVersion: 'v1',
context:
{ cluster: '192-168-99-100:8443',
namespace: 'for-node-client-testing',
user: 'developer/192-168-99-100:8443' },
user: { token: 'zVBd1ZFeJqEAILJgimm4-gZJauaw3PW4EVqV_peEZ3U' },
cluster: 'https://192.168.99.100:8443' }
const openshiftRestClient = require('openshift-rest-client');
This can be obtained using the [openshift-config-loader](https://www.npmjs.com/package/openshift-config-loader)
openshiftRestClient().then((client) => {
// Use the client object to find a list of projects, for example
client.projects.findAll().then((projects) => {
console.log(projects);
});
});
By default, the config loader with look for a config at `~/.kube/config`
### Advanced Usage
Code:
By default, the openshift-rest-client will use the [openshift-config-loader](https://www.npmjs.com/package/openshift-config-loader) module to get your openshift configuration.
const openshiftConfigLoader = require('openshift-config-loader');
You can pass in a custom config object by using the `settings` object
const openshiftRestClient = require('openshift-rest-client');
const settings = {};
openshiftConfigLoader(settings).then((config) => {
openshiftRestClient(config).then((client) => {
// Use the client object to find a list of projects, for example
client.projects.findAll().then((projects) => {
console.log(projects);
});
const customConfig = {
apiVersion: 'v1',
context:
{ cluster: '192-168-99-100:8443',
namespace: 'for-node-client-testing',
user: 'developer/192-168-99-100:8443' },
user: { token: 'zVBd1ZFeJqEAILJgimm4-gZJauaw3PW4EVqV_peEZ3U' },
cluster: 'https://192.168.99.100:8443' }
};
settings.config = customConfig;
openshiftRestClient(settings).then((client) => {
// Use the client object to find a list of projects, for example
client.projects.findAll().then((projects) => {
console.log(projects);
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc